home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Compilers⁄Interps / GCC 1.37.1r15 Full / Sources / expr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-09  |  171.4 KB  |  5,665 lines  |  [TEXT/MPS ]

  1. /* Convert tree expression to rtl instructions, for GNU compiler.
  2.    Copyright (C) 1988 Free Software Foundation, Inc.
  3.    Copyright (C) 1989, 1990 Apple Computer, Inc.
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 1, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21.  
  22. #include <stddef.h>
  23. #include <stdio.h>
  24. #include <types.h>
  25. #include "config.h"
  26. #include "rtl.h"
  27. #include "tree.h"
  28. #include "flags.h"
  29. #include "insn-flags.h"
  30. #include "insn-codes.h"
  31. #include "expr.h"
  32. #include "insn-config.h"
  33. #include "recog.h"
  34. #include "gvarargs.h"
  35. #include "typeclass.h"
  36.  
  37. /* Decide whether a function's arguments should be processed
  38.    from first to last or from last to first.  */
  39.  
  40. #ifdef APPLE_C
  41. /* assume stack grows down and push rounding defined */
  42. int push_args_reversed = 1;
  43. #else
  44. #ifdef STACK_GROWS_DOWNWARD
  45. #ifdef PUSH_ROUNDING
  46. #define PUSH_ARGS_REVERSED    /* If it's last to first */
  47. #endif
  48. #endif
  49. #endif /* APPLE_C */
  50.  
  51. /* Like STACK_BOUNDARY but in units of bytes, not bits.  */
  52. #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
  53.  
  54. /* If this is nonzero, we do not bother generating VOLATILE
  55.    around volatile memory references, and we are willing to
  56.    output indirect addresses.  If cse is to follow, we reject
  57.    indirect addresses so a useful potential cse is generated;
  58.    if it is used only once, instruction combination will produce
  59.    the same indirect address eventually.  */
  60. int cse_not_expected;
  61.  
  62. /* Nonzero to generate code for all the subroutines within an
  63.    expression before generating the upper levels of the expression.
  64.    Nowadays this is never zero.  */
  65. int do_preexpand_calls = 1;
  66.  
  67. /* Number of units that we should eventually pop off the stack.
  68.    These are the arguments to function calls that have already returned.  */
  69. int pending_stack_adjust;
  70.  
  71. /* Nonzero means stack pops must not be deferred, and deferred stack
  72.    pops must not be output.  It is nonzero inside a function call,
  73.    inside a conditional expression, inside a statement expression,
  74.    and in other cases as well.  */
  75. int inhibit_defer_pop;
  76.  
  77. /* A list of all cleanups which belong to the arguments of
  78.    function calls being expanded by expand_call.  */
  79. static tree cleanups_of_this_call;
  80.  
  81. /* Nonzero means current function may call alloca
  82.    as a subroutine.  (__builtin_alloca does not count.)  */
  83. int may_call_alloca;
  84.  
  85. rtx store_expr ();
  86. static void store_constructor ();
  87. static rtx store_field ();
  88. static rtx expand_call ();
  89. static void emit_call_1 ();
  90. static rtx prepare_call_address ();
  91. static rtx expand_builtin ();
  92. static rtx compare ();
  93. static rtx compare_constants ();
  94. static rtx compare1 ();
  95. static rtx do_store_flag ();
  96. static void preexpand_calls ();
  97. static rtx expand_increment ();
  98. static void init_queue ();
  99.  
  100. void do_pending_stack_adjust ();
  101.  
  102. /* MOVE_RATIO is the number of move instructions that is better than
  103.    a block move.  */
  104.  
  105. #ifndef MOVE_RATIO
  106. #if defined (HAVE_movstrqi) || defined (HAVE_movstrhi) || defined (HAVE_movstrsi)
  107. #define MOVE_RATIO 2
  108. #else
  109. /* A value of around 6 would minimize code size; infinity would minimize
  110.    execution time.  */
  111. #define MOVE_RATIO 15
  112. #endif
  113. #endif
  114.  
  115. /* Table indexed by tree code giving 1 if the code is for a
  116.    comparison operation, or anything that is most easily
  117.    computed with a conditional branch.
  118.  
  119.    We include tree.def to give it the proper length.
  120.    The contents thus created are irrelevant.
  121.    The real contents are initialized in init_comparisons.  */
  122.  
  123. #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) 0,
  124.  
  125. static char comparison_code[] = {
  126. #include "tree.def"
  127. };
  128. #undef DEFTREECODE
  129.  
  130. /* This is run once per compilation.  */
  131.  
  132. void
  133. init_comparisons ()
  134. {
  135.   comparison_code[(int) EQ_EXPR] = 1;
  136.   comparison_code[(int) NE_EXPR] = 1;
  137.   comparison_code[(int) LT_EXPR] = 1;
  138.   comparison_code[(int) GT_EXPR] = 1;
  139.   comparison_code[(int) LE_EXPR] = 1;
  140.   comparison_code[(int) GE_EXPR] = 1;
  141. }
  142.  
  143. /* This is run at the start of compiling a function.  */
  144.  
  145. void
  146. init_expr ()
  147. {
  148.   init_queue ();
  149.   may_call_alloca = 0;
  150. }
  151.  
  152. /* Manage the queue of increment instructions to be output
  153.    for POSTINCREMENT_EXPR expressions, etc.  */
  154.  
  155. static rtx pending_chain;
  156.  
  157. /* Queue up to increment (or change) VAR later.  BODY says how:
  158.    BODY should be the same thing you would pass to emit_insn
  159.    to increment right away.  It will go to emit_insn later on.
  160.  
  161.    The value is a QUEUED expression to be used in place of VAR
  162.    where you want to guarantee the pre-incrementation value of VAR.  */
  163.  
  164. static rtx
  165. enqueue_insn (var, body)
  166.      rtx var, body;
  167. {
  168.   pending_chain = gen_rtx (QUEUED, GET_MODE (var),
  169.                var, 0, 0, body, pending_chain);
  170.   return pending_chain;
  171. }
  172.  
  173. /* Use protect_from_queue to convert a QUEUED expression
  174.    into something that you can put immediately into an instruction.
  175.    If the queued incrementation has not happened yet,
  176.    protect_from_queue returns the variable itself.
  177.    If the incrementation has happened, protect_from_queue returns a temp
  178.    that contains a copy of the old value of the variable.
  179.  
  180.    Any time an rtx which might possibly be a QUEUED is to be put
  181.    into an instruction, it must be passed through protect_from_queue first.
  182.    QUEUED expressions are not meaningful in instructions.
  183.  
  184.    Do not pass a value through protect_from_queue and then hold
  185.    on to it for a while before putting it in an instruction!
  186.    If the queue is flushed in between, incorrect code will result.  */
  187.  
  188. rtx
  189. protect_from_queue (x, modify)
  190.      register rtx x;
  191.      int modify;
  192. {
  193.   register RTX_CODE code = GET_CODE (x);
  194.   if (code != QUEUED)
  195.     {
  196.       /* A special hack for read access to (MEM (QUEUED ...))
  197.      to facilitate use of autoincrement.
  198.      Make a copy of the contents of the memory location
  199.      rather than a copy of the address.  */
  200.       if (code == MEM && GET_CODE (XEXP (x, 0)) == QUEUED && !modify)
  201.     {
  202.       register rtx y = XEXP (x, 0);
  203.       XEXP (x, 0) = QUEUED_VAR (y);
  204.       if (QUEUED_INSN (y))
  205.         {
  206.           register rtx temp = gen_reg_rtx (GET_MODE (x));
  207.           emit_insn_before (gen_move_insn (temp, x),
  208.                 QUEUED_INSN (y));
  209.           return temp;
  210.         }
  211.       return x;
  212.     }
  213.       /* Otherwise, recursively protect the subexpressions of all
  214.      the kinds of rtx's that can contain a QUEUED.  */
  215.       if (code == MEM)
  216.     XEXP (x, 0) = protect_from_queue (XEXP (x, 0), 0);
  217.       else if (code == PLUS || code == MULT)
  218.     {
  219.       XEXP (x, 0) = protect_from_queue (XEXP (x, 0), 0);
  220.       XEXP (x, 1) = protect_from_queue (XEXP (x, 1), 0);
  221.     }
  222.       return x;
  223.     }
  224.   /* If the increment has not happened, use the variable itself.  */
  225.   if (QUEUED_INSN (x) == 0)
  226.     return QUEUED_VAR (x);
  227.   /* If the increment has happened and a pre-increment copy exists,
  228.      use that copy.  */
  229.   if (QUEUED_COPY (x) != 0)
  230.     return QUEUED_COPY (x);
  231.   /* The increment has happened but we haven't set up a pre-increment copy.
  232.      Set one up now, and use it.  */
  233.   QUEUED_COPY (x) = gen_reg_rtx (GET_MODE (QUEUED_VAR (x)));
  234.   emit_insn_before (gen_move_insn (QUEUED_COPY (x), QUEUED_VAR (x)),
  235.             QUEUED_INSN (x));
  236.   return QUEUED_COPY (x);
  237. }
  238.  
  239. /* Return nonzero if X contains a QUEUED expression:
  240.    if it contains anything that will be altered by a queued increment.
  241.    We handle only combinations of MEM, PLUS, MINUS and MULT operators
  242.    since memory addresses generally contain only those.  */
  243.  
  244. static int
  245. queued_subexp_p (x)
  246.      rtx x;
  247. {
  248.   register enum rtx_code code = GET_CODE (x);
  249.   switch (code)
  250.     {
  251.     case QUEUED:
  252.       return 1;
  253.     case MEM:
  254.       return queued_subexp_p (XEXP (x, 0));
  255.     case MULT:
  256.     case PLUS:
  257.     case MINUS:
  258.       return queued_subexp_p (XEXP (x, 0))
  259.     || queued_subexp_p (XEXP (x, 1));
  260.     }
  261.   return 0;
  262. }
  263.  
  264. /* Perform all the pending incrementations.  */
  265.  
  266. void
  267. emit_queue ()
  268. {
  269.   register rtx p;
  270.   while (p = pending_chain)
  271.     {
  272.       QUEUED_INSN (p) = emit_insn (QUEUED_BODY (p));
  273.       pending_chain = QUEUED_NEXT (p);
  274.     }
  275. }
  276.  
  277. static void
  278. init_queue ()
  279. {
  280.   if (pending_chain)
  281.     abort ();
  282. }
  283.  
  284. /* Copy data from FROM to TO, where the machine modes are not the same.
  285.    Both modes may be integer, or both may be floating.
  286.    UNSIGNEDP should be nonzero if FROM is an unsigned type.
  287.    This causes zero-extension instead of sign-extension.  */
  288.  
  289. void
  290. convert_move (to, from, unsignedp)
  291.      register rtx to, from;
  292.      int unsignedp;
  293. {
  294.   enum machine_mode to_mode = GET_MODE (to);
  295.   enum machine_mode from_mode = GET_MODE (from);
  296.   int to_real = GET_MODE_CLASS (to_mode) == MODE_FLOAT;
  297.   int from_real = GET_MODE_CLASS (from_mode) == MODE_FLOAT;
  298.   int extending = (int) to_mode > (int) from_mode;
  299.  
  300.   to = protect_from_queue (to, 1);
  301.   from = protect_from_queue (from, 0);
  302.  
  303.   if (to_real != from_real)
  304.     abort ();
  305.  
  306.   if (to_mode == from_mode
  307.       || (from_mode == VOIDmode && CONSTANT_P (from)))
  308.     {
  309.       emit_move_insn (to, from);
  310.       return;
  311.     }
  312.  
  313.   if (to_real)
  314.     {
  315. #ifdef APPLE_HAX
  316.       if (to_mode == XFmode)
  317.     {
  318. #ifdef HAVE_extendsfxf2
  319.       if (from_mode == SFmode && HAVE_extendsfxf2 && extending)
  320.         {
  321.           emit_unop_insn (CODE_FOR_extendsfxf2, to, from, UNKNOWN);
  322.           return;
  323.         }
  324. #endif
  325. #ifdef HAVE_extenddfxf2
  326.       if (from_mode == DFmode && HAVE_extenddfxf2 && extending)
  327.         {
  328.           emit_unop_insn (CODE_FOR_extenddfxf2, to, from, UNKNOWN);
  329.           return;
  330.         }
  331. #endif
  332.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, ((from_mode == SFmode)
  333.                               ? "__extendsfxf2"
  334.                               : "__extenddfxf2")),
  335.                  0, GET_MODE (to), 1, from, from_mode);
  336.       emit_move_insn (to, hard_libcall_value (GET_MODE (to)));
  337.       return;
  338.     }
  339.       /* OK, now to_mode is sf or df, but from_mode might still be xf */
  340.       if (from_mode == XFmode)
  341.     {
  342. #ifdef HAVE_truncxfsf2
  343.       if (HAVE_truncxfsf2 && to_mode == SFmode)
  344.         {
  345.           emit_unop_insn (CODE_FOR_truncxfsf2, to, from, UNKNOWN);
  346.           return;
  347.         }
  348. #endif
  349. #ifdef HAVE_truncxfdf2
  350.       if (HAVE_truncxfdf2 && to_mode == DFmode)
  351.         {
  352.           emit_unop_insn (CODE_FOR_truncxfdf2, to, from, UNKNOWN);
  353.           return;
  354.         }
  355. #endif
  356.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, ((to_mode == SFmode)
  357.                               ? "__truncxfsf2"
  358.                               : "__truncxfdf2")),
  359.                  0, GET_MODE (to), 1, from, from_mode);
  360.       emit_move_insn (to, hard_libcall_value (GET_MODE (to)));
  361.       return;
  362.         }
  363.       /* all the longer modes should be taken care of now */
  364. #ifdef HAVE_extendsfdf2
  365.       if (HAVE_extendsfdf2 && extending)
  366.     {
  367.       emit_unop_insn (CODE_FOR_extendsfdf2, to, from, UNKNOWN);
  368.       return;
  369.     }
  370. #else
  371.       /* try using xf as an intermediary */
  372. #if defined(HAVE_extendsfxf2) && defined(HAVE_truncxfdf2)
  373.       if (HAVE_extendsfxf2 && HAVE_truncxfdf2 && extending)
  374.     {
  375.       rtx tmp = gen_reg_rtx(XFmode);
  376.  
  377.       emit_unop_insn (CODE_FOR_extendsfxf2, tmp, from, UNKNOWN);
  378.       emit_unop_insn (CODE_FOR_truncxfdf2, to, tmp, UNKNOWN);
  379.       return;
  380.         }
  381. #endif
  382. #endif /* HAVE_extendsfdf2 */
  383. #ifdef HAVE_truncdfsf2
  384.       if (HAVE_truncdfsf2 && ! extending)
  385.     {
  386.       emit_unop_insn (CODE_FOR_truncdfsf2, to, from, UNKNOWN);
  387.       return;
  388.     }
  389. #else
  390.       /* try using xf as an intermediary */
  391. #if defined(HAVE_extenddfxf2) && defined(HAVE_truncxfsf2)
  392.       if (HAVE_extenddfxf2 && HAVE_truncxfsf2 && ! extending)
  393.     {
  394.       rtx tmp = gen_reg_rtx(XFmode);
  395.  
  396.       emit_unop_insn (CODE_FOR_extenddfxf2, tmp, from, UNKNOWN);
  397.       emit_unop_insn (CODE_FOR_truncxfsf2, to, tmp, UNKNOWN);
  398.       return;
  399.         }
  400. #endif
  401. #endif /* HAVE_truncdfsf2 */
  402. #else /* n APPLE_HAX */
  403. #ifdef HAVE_extendsfdf2
  404.       if (HAVE_extendsfdf2 && extending)
  405.     {
  406.       emit_unop_insn (CODE_FOR_extendsfdf2, to, from, UNKNOWN);
  407.       return;
  408.     }
  409. #endif
  410. #ifdef HAVE_truncdfsf2
  411.       if (HAVE_truncdfsf2 && ! extending)
  412.     {
  413.       emit_unop_insn (CODE_FOR_truncdfsf2, to, from, UNKNOWN);
  414.       return;
  415.     }
  416. #endif
  417. #endif /* APPLE_HAX */
  418.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, (extending
  419.                               ? "__extendsfdf2"
  420.                               : "__truncdfsf2")), 0,
  421.              GET_MODE (to), 1,
  422.              from,  (extending ? SFmode : DFmode));
  423.       emit_move_insn (to, hard_libcall_value (GET_MODE (to)));
  424.       return;
  425.     }
  426.  
  427.   /* Now both modes are integers.  */
  428.  
  429.   if (to_mode == DImode)
  430.     {
  431.       if (unsignedp)
  432.     {
  433. #ifdef HAVE_zero_extendsidi2
  434.       if (HAVE_zero_extendsidi2 && from_mode == SImode)
  435.         emit_unop_insn (CODE_FOR_zero_extendsidi2, to, from, ZERO_EXTEND);
  436.       else
  437. #endif
  438. #ifdef HAVE_zero_extendhidi2
  439.       if (HAVE_zero_extendhidi2 && from_mode == HImode)
  440.         emit_unop_insn (CODE_FOR_zero_extendhidi2, to, from, ZERO_EXTEND);
  441.       else
  442. #endif
  443. #ifdef HAVE_zero_extendqidi2
  444.       if (HAVE_zero_extendqidi2 && from_mode == QImode)
  445.         emit_unop_insn (CODE_FOR_zero_extendqidi2, to, from, ZERO_EXTEND);
  446.       else
  447. #endif
  448. #ifdef HAVE_zero_extendsidi2
  449.       if (HAVE_zero_extendsidi2)
  450.         {
  451.           convert_move (gen_lowpart (SImode, to), from, unsignedp);
  452.           emit_unop_insn (CODE_FOR_zero_extendsidi2, to,
  453.                   gen_lowpart (SImode, to), ZERO_EXTEND);
  454.         }
  455.       else
  456. #endif
  457.         {
  458.           emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
  459.           convert_move (gen_lowpart (SImode, to), from, unsignedp);
  460.           emit_clr_insn (gen_highpart (SImode, to));
  461.         }
  462.     }
  463. #ifdef HAVE_extendsidi2
  464.       else if (HAVE_extendsidi2 && from_mode == SImode)
  465.     emit_unop_insn (CODE_FOR_extendsidi2, to, from, SIGN_EXTEND);
  466. #endif
  467. #ifdef HAVE_extendhidi2
  468.       else if (HAVE_extendhidi2 && from_mode == HImode)
  469.     emit_unop_insn (CODE_FOR_extendhidi2, to, from, SIGN_EXTEND);
  470. #endif
  471. #ifdef HAVE_extendqidi2
  472.       else if (HAVE_extendqidi2 && from_mode == QImode)
  473.     emit_unop_insn (CODE_FOR_extendqidi2, to, from, SIGN_EXTEND);
  474. #endif
  475. #ifdef HAVE_extendsidi2
  476.       else if (HAVE_extendsidi2)
  477.     {
  478.       convert_move (gen_lowpart (SImode, to), from, unsignedp);
  479.       emit_unop_insn (CODE_FOR_extendsidi2, to,
  480.               gen_lowpart (SImode, to), SIGN_EXTEND);
  481.     }
  482. #endif
  483. #ifdef HAVE_slt
  484.       else if (HAVE_slt && insn_operand_mode[(int) CODE_FOR_slt][0] == SImode)
  485.     {
  486.       emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
  487.       convert_move (gen_lowpart (SImode, to), from, unsignedp);
  488.       emit_insn (gen_slt (gen_highpart (SImode, to)));
  489.     }
  490. #endif
  491.       else
  492.     {
  493.       register rtx label = gen_label_rtx ();
  494.  
  495.       emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
  496.       emit_clr_insn (gen_highpart (SImode, to));
  497.       convert_move (gen_lowpart (SImode, to), from, unsignedp);
  498.       emit_cmp_insn (gen_lowpart (SImode, to),
  499.              gen_rtx (CONST_INT, VOIDmode, 0),
  500.              0, 0, 0);
  501.       NO_DEFER_POP;
  502.       emit_jump_insn (gen_bge (label));
  503.       expand_unop (SImode, one_cmpl_optab,
  504.                gen_highpart (SImode, to), gen_highpart (SImode, to),
  505.                1);
  506.       emit_label (label);
  507.       OK_DEFER_POP;
  508.     }
  509.       return;
  510.     }
  511.  
  512.   if (from_mode == DImode)
  513.     {
  514.       convert_move (to, gen_lowpart (SImode, from), 0);
  515.       return;
  516.     }
  517.  
  518.   /* Now follow all the conversions between integers
  519.      no more than a word long.  */
  520.  
  521.   /* For truncation, usually we can just refer to FROM in a narrower mode.  */
  522.   if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode)
  523.       && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode),
  524.                 GET_MODE_BITSIZE (from_mode))
  525.       && ((GET_CODE (from) == MEM
  526.        && ! MEM_VOLATILE_P (from)
  527.        && ! mode_dependent_address_p (XEXP (from, 0)))
  528.       || GET_CODE (from) == REG
  529.       || GET_CODE (from) == SUBREG))
  530.     {
  531.       emit_move_insn (to, gen_lowpart (to_mode, from));
  532.       return;
  533.     }
  534.  
  535.   if (to_mode == SImode && from_mode == HImode)
  536.     {
  537.       if (unsignedp)
  538.     {
  539. #ifdef HAVE_zero_extendhisi2
  540.       if (HAVE_zero_extendhisi2)
  541.         emit_unop_insn (CODE_FOR_zero_extendhisi2, to, from, ZERO_EXTEND);
  542.       else
  543. #endif
  544.         abort ();
  545.     }
  546.       else
  547.     {
  548. #ifdef HAVE_extendhisi2
  549.       if (HAVE_extendhisi2)
  550.         emit_unop_insn (CODE_FOR_extendhisi2, to, from, SIGN_EXTEND);
  551.       else
  552. #endif
  553.         abort ();
  554.     }
  555.       return;
  556.     }
  557.  
  558.   if (to_mode == SImode && from_mode == QImode)
  559.     {
  560.       if (unsignedp)
  561.     {
  562. #ifdef HAVE_zero_extendqisi2
  563.       if (HAVE_zero_extendqisi2)
  564.         {
  565.           emit_unop_insn (CODE_FOR_zero_extendqisi2, to, from, ZERO_EXTEND);
  566.           return;
  567.         }
  568. #endif
  569. #if defined (HAVE_zero_extendqihi2) && defined (HAVE_extendhisi2)
  570.       if (HAVE_zero_extendqihi2 && HAVE_extendhisi2)
  571.         {
  572.           register rtx temp = gen_reg_rtx (HImode);
  573.           emit_unop_insn (CODE_FOR_zero_extendqihi2, temp, from, ZERO_EXTEND);
  574.           emit_unop_insn (CODE_FOR_extendhisi2, to, temp, SIGN_EXTEND);
  575.           return;
  576.         }
  577. #endif
  578.     }
  579.       else
  580.     {
  581. #ifdef HAVE_extendqisi2
  582.       if (HAVE_extendqisi2)
  583.         {
  584.           emit_unop_insn (CODE_FOR_extendqisi2, to, from, SIGN_EXTEND);
  585.           return;
  586.         }
  587. #endif
  588. #if defined (HAVE_extendqihi2) && defined (HAVE_extendhisi2)
  589.       if (HAVE_extendqihi2 && HAVE_extendhisi2)
  590.         {
  591.           register rtx temp = gen_reg_rtx (HImode);
  592.           emit_unop_insn (CODE_FOR_extendqihi2, temp, from, SIGN_EXTEND);
  593.           emit_unop_insn (CODE_FOR_extendhisi2, to, temp, SIGN_EXTEND);
  594.           return;
  595.         }
  596. #endif
  597.     }
  598.       abort ();
  599.     }
  600.  
  601.   if (to_mode == HImode && from_mode == QImode)
  602.     {
  603.       if (unsignedp)
  604.     {
  605. #ifdef HAVE_zero_extendqihi2
  606.       if (HAVE_zero_extendqihi2)
  607.         {
  608.           emit_unop_insn (CODE_FOR_zero_extendqihi2, to, from, ZERO_EXTEND);
  609.           return;
  610.         }
  611. #endif
  612.     }
  613.       else
  614.     {
  615. #ifdef HAVE_extendqihi2
  616.       if (HAVE_extendqihi2)
  617.         {
  618.           emit_unop_insn (CODE_FOR_extendqihi2, to, from, SIGN_EXTEND);
  619.           return;
  620.         }
  621. #endif
  622.     }
  623.       abort ();
  624.     }
  625.  
  626. #if 0 /* This seems to be redundant with code 100 lines up.  */
  627.  
  628.   /* Now we are truncating an integer to a smaller one.
  629.      If the result is a temporary, we might as well just copy it,
  630.      since only the low-order part of the result needs to be valid
  631.      and it is valid with no change.  */
  632.  
  633.   if (GET_CODE (to) == REG)
  634.     {
  635.       if (GET_CODE (from) == REG)
  636.     {
  637.       emit_move_insn (to, gen_lowpart (GET_MODE (to), from));
  638.       return;
  639.     }
  640.       else if (GET_CODE (from) == SUBREG)
  641.     {
  642.       from = copy_rtx (from);
  643.       /* This is safe since FROM is not more than one word.  */
  644.       PUT_MODE (from, GET_MODE (to));
  645.       emit_move_insn (to, from);
  646.       return;
  647.     }
  648. #ifndef BYTES_BIG_ENDIAN
  649.       else if (GET_CODE (from) == MEM)
  650.     {
  651.       register rtx addr = XEXP (from, 0);
  652.       if (memory_address_p (GET_MODE (to), addr))
  653.         {
  654.           emit_move_insn (to, gen_rtx (MEM, GET_MODE (to), addr));
  655.           return;
  656.         }
  657.     }
  658. #endif /* not BYTES_BIG_ENDIAN */
  659.     }
  660. #endif /* 0 */
  661.  
  662.   if (from_mode == SImode && to_mode == HImode)
  663.     {
  664. #ifdef HAVE_truncsihi2
  665.       if (HAVE_truncsihi2)
  666.     {
  667.       emit_unop_insn (CODE_FOR_truncsihi2, to, from, UNKNOWN);
  668.       return;
  669.     }
  670. #endif
  671.       abort ();
  672.     }
  673.  
  674.   if (from_mode == SImode && to_mode == QImode)
  675.     {
  676. #ifdef HAVE_truncsiqi2
  677.       if (HAVE_truncsiqi2)
  678.     {
  679.       emit_unop_insn (CODE_FOR_truncsiqi2, to, from, UNKNOWN);
  680.       return;
  681.     }
  682. #endif
  683.       abort ();
  684.     }
  685.  
  686.   if (from_mode == HImode && to_mode == QImode)
  687.     {
  688. #ifdef HAVE_trunchiqi2
  689.       if (HAVE_trunchiqi2)
  690.     {
  691.       emit_unop_insn (CODE_FOR_trunchiqi2, to, from, UNKNOWN);
  692.       return;
  693.     }
  694. #endif
  695.       abort ();
  696.     }
  697.  
  698.   /* Mode combination is not recognized.  */
  699.   abort ();
  700. }
  701.  
  702. /* Return an rtx for a value that would result
  703.    from converting X to mode MODE.
  704.    Both X and MODE may be floating, or both integer.
  705.    UNSIGNEDP is nonzero if X is an unsigned value.
  706.    This can be done by referring to a part of X in place
  707.    or by copying to a new temporary with conversion.  */
  708.  
  709. rtx
  710. convert_to_mode (mode, x, unsignedp)
  711.      enum machine_mode mode;
  712.      rtx x;
  713.      int unsignedp;
  714. {
  715.   register rtx temp;
  716.   if (mode == GET_MODE (x))
  717.     return x;
  718.   if (integer_mode_p (mode)
  719.       && GET_MODE_SIZE (mode) <= GET_MODE_SIZE (GET_MODE (x))
  720.       && ! (GET_CODE (x) == MEM && MEM_VOLATILE_P (x)))
  721.     return gen_lowpart (mode, x);
  722.   temp = gen_reg_rtx (mode);
  723.   convert_move (temp, x, unsignedp);
  724.   return temp;
  725. }
  726.  
  727. int
  728. integer_mode_p (mode)
  729.      enum machine_mode mode;
  730. {
  731.   return (int) mode > (int) VOIDmode && (int) mode <= (int) TImode;
  732. }
  733.  
  734. /* Generate several move instructions to copy LEN bytes
  735.    from block FROM to block TO.  (These are MEM rtx's with BLKmode).
  736.    The caller must pass FROM and TO
  737.     through protect_from_queue before calling.
  738.    ALIGN (in bytes) is maximum alignment we can assume.  */
  739.  
  740. struct move_by_pieces
  741. {
  742.   rtx to;
  743.   rtx to_addr;
  744.   int autinc_to;
  745.   int explicit_inc_to;
  746.   rtx from;
  747.   rtx from_addr;
  748.   int autinc_from;
  749.   int explicit_inc_from;
  750.   int len;
  751.   int offset;
  752.   int reverse;
  753. };
  754.  
  755. static void move_by_pieces_1 ();
  756. static int move_by_pieces_ninsns ();
  757.  
  758. static void
  759. move_by_pieces (to, from, len, align)
  760.      rtx to, from;
  761.      int len, align;
  762. {
  763.   struct move_by_pieces data;
  764.   rtx to_addr = XEXP (to, 0), from_addr = XEXP (from, 0);
  765.  
  766.   data.offset = 0;
  767.   data.to_addr = to_addr;
  768.   data.from_addr = from_addr;
  769.   data.to = to;
  770.   data.from = from;
  771.   data.autinc_to
  772.     = (GET_CODE (to_addr) == PRE_INC || GET_CODE (to_addr) == PRE_DEC
  773.        || GET_CODE (to_addr) == POST_INC || GET_CODE (to_addr) == POST_DEC);
  774.   data.autinc_from
  775.     = (GET_CODE (from_addr) == PRE_INC || GET_CODE (from_addr) == PRE_DEC
  776.        || GET_CODE (from_addr) == POST_INC
  777.        || GET_CODE (from_addr) == POST_DEC);
  778.  
  779.   data.explicit_inc_from = 0;
  780.   data.explicit_inc_to = 0;
  781.   data.reverse
  782.     = (GET_CODE (to_addr) == PRE_DEC || GET_CODE (to_addr) == POST_DEC);
  783.   if (data.reverse) data.offset = len;
  784.   data.len = len;
  785.  
  786.   /* If copying requires more than two move insns,
  787.      copy addresses to registers (to make displacements shorter)
  788.      and use post-increment if available.  */
  789.   if (!(data.autinc_from && data.autinc_to)
  790.       && move_by_pieces_ninsns (len, align) > 2)
  791.     {
  792. #ifdef HAVE_PRE_DECREMENT
  793.       if (data.reverse && ! data.autinc_from)
  794.     {
  795.       data.from_addr = copy_addr_to_reg (plus_constant (from_addr, len));
  796.       data.autinc_from = 1;
  797.       data.explicit_inc_from = -1;
  798.     }
  799. #endif
  800. #ifdef HAVE_POST_INCREMENT
  801.       if (! data.autinc_from)
  802.     {
  803.       data.from_addr = copy_addr_to_reg (from_addr);
  804.       data.autinc_from = 1;
  805.       data.explicit_inc_from = 1;
  806.     }
  807. #endif
  808.       if (!data.autinc_from && CONSTANT_P (from_addr))
  809.     data.from_addr = copy_addr_to_reg (from_addr);
  810. #ifdef HAVE_PRE_DECREMENT
  811.       if (data.reverse && ! data.autinc_to)
  812.     {
  813.       data.to_addr = copy_addr_to_reg (plus_constant (to_addr, len));
  814.       data.autinc_to = 1;
  815.       data.explicit_inc_to = -1;
  816.     }
  817. #endif
  818. #ifdef HAVE_POST_INCREMENT
  819.       if (! data.reverse && ! data.autinc_to)
  820.     {
  821.       data.to_addr = copy_addr_to_reg (to_addr);
  822.       data.autinc_to = 1;
  823.       data.explicit_inc_to = 1;
  824.     }
  825. #endif
  826.       if (!data.autinc_to && CONSTANT_P (to_addr))
  827.     data.to_addr = copy_addr_to_reg (to_addr);
  828.     }
  829.  
  830. #ifdef STRICT_ALIGNMENT
  831.   if (align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  832.     align = MOVE_MAX;
  833. #else
  834.   align = MOVE_MAX;
  835. #endif
  836.  
  837. #ifdef HAVE_movti
  838.   if (HAVE_movti && align >= GET_MODE_SIZE (TImode))
  839.     move_by_pieces_1 (gen_movti, TImode, &data);
  840. #endif
  841. #ifdef HAVE_movdi
  842.   if (HAVE_movdi && align >= GET_MODE_SIZE (DImode))
  843.     move_by_pieces_1 (gen_movdi, DImode, &data);
  844. #endif
  845. #ifdef HAVE_movsi
  846.   if (align >= GET_MODE_SIZE (SImode))
  847.     move_by_pieces_1 (gen_movsi, SImode, &data);
  848. #endif
  849. #ifdef HAVE_movhi
  850.   if (HAVE_movhi && align >= GET_MODE_SIZE (HImode))
  851.     move_by_pieces_1 (gen_movhi, HImode, &data);
  852. #endif
  853. #ifdef HAVE_movqi
  854.   move_by_pieces_1 (gen_movqi, QImode, &data);
  855. #else
  856.   movqi instruction required in machine description
  857. #endif
  858. }
  859.  
  860. /* Return number of insns required to move L bytes by pieces.
  861.    ALIGN (in bytes) is maximum alignment we can assume.  */
  862.  
  863. static int
  864. move_by_pieces_ninsns (l, align)
  865.      unsigned int l;
  866.      int align;
  867. {
  868.   register int n_insns = 0;
  869.  
  870. #ifdef STRICT_ALIGNMENT
  871.   if (align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  872.     align = MOVE_MAX;
  873. #else
  874.   align = MOVE_MAX;
  875. #endif
  876.  
  877. #ifdef HAVE_movti
  878.   if (HAVE_movti && align >= GET_MODE_SIZE (TImode))
  879.     n_insns += l / GET_MODE_SIZE (TImode), l %= GET_MODE_SIZE (TImode);
  880. #endif
  881. #ifdef HAVE_movdi
  882.   if (HAVE_movdi && align >= GET_MODE_SIZE (DImode))
  883.     n_insns += l / GET_MODE_SIZE (DImode), l %= GET_MODE_SIZE (DImode);
  884. #endif
  885. #ifdef HAVE_movsi
  886.   if (HAVE_movsi && align >= GET_MODE_SIZE (SImode))
  887.     n_insns += l / GET_MODE_SIZE (SImode), l %= GET_MODE_SIZE (SImode);
  888. #endif
  889. #ifdef HAVE_movhi
  890.   if (HAVE_movhi && align >= GET_MODE_SIZE (HImode))
  891.     n_insns += l / GET_MODE_SIZE (HImode), l %= GET_MODE_SIZE (HImode);
  892. #endif
  893.   n_insns += l;
  894.  
  895.   return n_insns;
  896. }
  897.  
  898. /* Subroutine of move_by_pieces.  Move as many bytes as appropriate
  899.    with move instructions for mode MODE.  GENFUN is the gen_... function
  900.    to make a move insn for that mode.  DATA has all the other info.  */
  901.  
  902. static void
  903. move_by_pieces_1 (genfun, mode, data)
  904.      rtx (*genfun) ();
  905.      enum machine_mode mode;
  906.      struct move_by_pieces *data;
  907. {
  908.   register int size = GET_MODE_SIZE (mode);
  909.   register rtx to1, from1;
  910.  
  911.   while (data->len >= size)
  912.     {
  913.       if (data->reverse) data->offset -= size;
  914.  
  915.       to1 = (data->autinc_to
  916.          ? gen_rtx (MEM, mode, data->to_addr)
  917.          : change_address (data->to, mode,
  918.                    plus_constant (data->to_addr, data->offset)));
  919.       from1 =
  920.     (data->autinc_from
  921.      ? gen_rtx (MEM, mode, data->from_addr)
  922.      : change_address (data->from, mode,
  923.                plus_constant (data->from_addr, data->offset)));
  924.  
  925. #ifdef HAVE_PRE_DECREMENT
  926.       if (data->explicit_inc_to < 0)
  927.     emit_insn (gen_sub2_insn (data->to_addr,
  928.                   gen_rtx (CONST_INT, VOIDmode, size)));
  929.       if (data->explicit_inc_from < 0)
  930.     emit_insn (gen_sub2_insn (data->from_addr,
  931.                   gen_rtx (CONST_INT, VOIDmode, size)));
  932. #endif
  933.  
  934.       emit_insn ((*genfun) (to1, from1));
  935. #ifdef HAVE_POST_INCREMENT
  936.       if (data->explicit_inc_to > 0)
  937.     emit_insn (gen_add2_insn (data->to_addr,
  938.                   gen_rtx (CONST_INT, VOIDmode, size)));
  939.       if (data->explicit_inc_from > 0)
  940.     emit_insn (gen_add2_insn (data->from_addr,
  941.                   gen_rtx (CONST_INT, VOIDmode, size)));
  942. #endif
  943.  
  944.       if (! data->reverse) data->offset += size;
  945.  
  946.       data->len -= size;
  947.     }
  948. }
  949.  
  950. /* Emit code to move a block Y to a block X.
  951.    This may be done with string-move instructions,
  952.    with multiple scalar move instructions, or with a library call.
  953.  
  954.    Both X and Y must be MEM rtx's (perhaps inside VOLATILE)
  955.    with mode BLKmode.
  956.    SIZE is an rtx that says how long they are.
  957.    ALIGN is the maximum alignment we can assume they have,
  958.    measured in bytes.  */
  959.  
  960. static void
  961. emit_block_move (x, y, size, align)
  962.      rtx x, y;
  963.      rtx size;
  964.      int align;
  965. {
  966.   if (GET_MODE (x) != BLKmode)
  967.     abort ();
  968.  
  969.   if (GET_MODE (y) != BLKmode)
  970.     abort ();
  971.  
  972.   x = protect_from_queue (x, 1);
  973.   y = protect_from_queue (y, 0);
  974.  
  975.   if (GET_CODE (x) != MEM)
  976.     abort ();
  977.   if (GET_CODE (y) != MEM)
  978.     abort ();
  979.   if (size == 0)
  980.     abort ();
  981.  
  982.   if (GET_CODE (size) == CONST_INT
  983.       && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
  984.       < MOVE_RATIO))
  985.     move_by_pieces (x, y, INTVAL (size), align);
  986.   else
  987.     {
  988.       /* Try the most limited insn first, because there's no point
  989.      including more than one in the machine description unless
  990.      the more limited one has some advantage.  */
  991. #ifdef HAVE_movstrqi
  992.       if (HAVE_movstrqi
  993.       && GET_CODE (size) == CONST_INT
  994.       && ((unsigned) INTVAL (size)
  995.           < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
  996.     {
  997.       emit_insn (gen_movstrqi (x, y, size,
  998.                    gen_rtx (CONST_INT, VOIDmode, align)));
  999.       return;
  1000.     }
  1001. #endif
  1002. #ifdef HAVE_movstrhi
  1003.       if (HAVE_movstrhi
  1004.       && GET_CODE (size) == CONST_INT
  1005.       && ((unsigned) INTVAL (size)
  1006.           < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
  1007.     {
  1008.       emit_insn (gen_movstrhi (x, y, size,
  1009.                    gen_rtx (CONST_INT, VOIDmode, align)));
  1010.       return;
  1011.     }
  1012. #endif
  1013. #ifdef HAVE_movstrsi
  1014.       if (HAVE_movstrsi)
  1015.     {
  1016.       emit_insn (gen_movstrsi (x, y, size,
  1017.                    gen_rtx (CONST_INT, VOIDmode, align)));
  1018.       return;
  1019.     }
  1020. #endif
  1021.  
  1022. #ifdef TARGET_MEM_FUNCTIONS
  1023.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memcpy"), 0,
  1024.              VOIDmode, 3, XEXP (x, 0), Pmode,
  1025.              XEXP (y, 0), Pmode,
  1026.              size, Pmode);
  1027. #else
  1028.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bcopy"), 0,
  1029.              VOIDmode, 3, XEXP (y, 0), Pmode,
  1030.              XEXP (x, 0), Pmode,
  1031.              size, Pmode);
  1032. #endif
  1033.     }
  1034. }
  1035.  
  1036. /* Copy all or part of a BLKmode value X into registers starting at REGNO.
  1037.    The number of registers to be filled is NREGS.  */
  1038.  
  1039. static void
  1040. move_block_to_reg (regno, x, nregs)
  1041.      int regno;
  1042.      rtx x;
  1043.      int nregs;
  1044. {
  1045.   int i;
  1046.   if (GET_CODE (x) == CONST_DOUBLE && x != dconst0_rtx)
  1047.     x = force_const_double_mem (x);
  1048.   for (i = 0; i < nregs; i++)
  1049.     {
  1050.       if (GET_CODE (x) == REG)
  1051.     emit_move_insn (gen_rtx (REG, SImode, regno + i),
  1052.             gen_rtx (SUBREG, SImode, x, i));
  1053.       else if (x == dconst0_rtx)
  1054.     emit_move_insn (gen_rtx (REG, SImode, regno + i),
  1055.             const0_rtx);
  1056.       else
  1057.     emit_move_insn (gen_rtx (REG, SImode, regno + i),
  1058.             gen_rtx (MEM, SImode,
  1059.                  memory_address (SImode,
  1060.                          plus_constant (XEXP (x, 0),
  1061.                                 i * GET_MODE_SIZE (SImode)))));
  1062.     }
  1063. }
  1064.  
  1065. /* Copy all or part of a BLKmode value X out of registers starting at REGNO.
  1066.    The number of registers to be filled is NREGS.  */
  1067.  
  1068. void
  1069. move_block_from_reg (regno, x, nregs)
  1070.      int regno;
  1071.      rtx x;
  1072.      int nregs;
  1073. {
  1074.   int i;
  1075.   for (i = 0; i < nregs; i++)
  1076.     {
  1077.       if (GET_CODE (x) == REG)
  1078.     emit_move_insn (gen_rtx (SUBREG, SImode, x, i),
  1079.             gen_rtx (REG, SImode, regno + i));
  1080.       else
  1081.     emit_move_insn (gen_rtx (MEM, SImode,
  1082.                  memory_address (SImode,
  1083.                          plus_constant (XEXP (x, 0),
  1084.                                 i * GET_MODE_SIZE (SImode)))),
  1085.             gen_rtx (REG, SImode, regno + i));
  1086.     }
  1087. }
  1088.  
  1089. /* Mark NREGS consecutive regs, starting at REGNO, as being live now.  */
  1090.  
  1091. static void
  1092. use_regs (regno, nregs)
  1093.      int regno;
  1094.      int nregs;
  1095. {
  1096.   int i;
  1097.   for (i = 0; i < nregs; i++)
  1098.     emit_insn (gen_rtx (USE, VOIDmode, gen_rtx (REG, SImode, regno + i)));
  1099. }
  1100.  
  1101. /* Write zeros through the storage of OBJECT.
  1102.    If OBJECT has BLKmode, SIZE is its length in bytes.  */
  1103.  
  1104. void
  1105. clear_storage (object, size)
  1106.      rtx object;
  1107.      int size;
  1108. {
  1109.   if (GET_MODE (object) == BLKmode)
  1110.     {
  1111. #ifdef TARGET_MEM_FUNCTIONS
  1112.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memset"), 0,
  1113.              VOIDmode, 3,
  1114.              XEXP (object, 0), Pmode, const0_rtx, Pmode,
  1115.              gen_rtx (CONST_INT, VOIDmode, size), Pmode);
  1116. #else
  1117.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bzero"), 0,
  1118.              VOIDmode, 2,
  1119.              XEXP (object, 0), Pmode,
  1120.              gen_rtx (CONST_INT, VOIDmode, size), Pmode);
  1121. #endif
  1122.     }
  1123.   else
  1124.     emit_move_insn (object, const0_rtx);
  1125. }
  1126.  
  1127. /* Generate code to copy Y into X.
  1128.    Both Y and X must have the same mode, except that
  1129.    Y can be a constant with VOIDmode.
  1130.    This mode cannot be BLKmode; use emit_block_move for that.
  1131.  
  1132.    Return the last instruction emitted.  */
  1133.  
  1134. rtx
  1135. emit_move_insn (x, y)
  1136.      rtx x, y;
  1137. {
  1138.   enum machine_mode mode = GET_MODE (x);
  1139.   x = protect_from_queue (x, 1);
  1140.   y = protect_from_queue (y, 0);
  1141.  
  1142.   if ((CONSTANT_P (y) || GET_CODE (y) == CONST_DOUBLE)
  1143.       && ! LEGITIMATE_CONSTANT_P (y))
  1144.     {
  1145.       y = force_const_mem (mode, y);
  1146.       if (! memory_address_p (mode, XEXP (y, 0)))
  1147.     y = gen_rtx (MEM, mode, memory_address (mode, XEXP (y, 0)));
  1148.     }
  1149.  
  1150.   if (mode == BLKmode)
  1151.     abort ();
  1152.   if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  1153.     return
  1154.       emit_insn (GEN_FCN (mov_optab->handlers[(int) mode].insn_code) (x, y));
  1155. #if 0
  1156.   /* It turns out you get much better optimization (in cse and flow)
  1157.      if you define movdi and movdf instruction patterns
  1158.      even if they must turn into multiple assembler instructions.  */
  1159.   else if (GET_MODE_SIZE (mode) >= GET_MODE_SIZE (SImode))
  1160.     {
  1161.       register int count = GET_MODE_SIZE (mode) / GET_MODE_SIZE (SImode);
  1162.       register int i;
  1163.       if (GET_CODE (y) == CONST_DOUBLE && y != dconst0_rtx)
  1164.     y = force_const_double_mem (y);
  1165.       for (i = 0; i < count; i++)
  1166.     {
  1167.       rtx x1, y1;
  1168.       if (GET_CODE (x) == REG)
  1169.         x1 = gen_rtx (SUBREG, SImode, x, i);
  1170.       else
  1171.         x1 = gen_rtx (MEM, SImode,
  1172.               memory_address (SImode,
  1173.                       plus_constant (XEXP (x, 0),
  1174.                              i * GET_MODE_SIZE (SImode))));
  1175.       if (GET_CODE (y) == REG)
  1176.         y1 = gen_rtx (SUBREG, SImode, y, i);
  1177.       else if (y == dconst0_rtx)
  1178.         y1 = const0_rtx;
  1179.       else
  1180.         y1 = gen_rtx (MEM, SImode,
  1181.               memory_address (SImode,
  1182.                       plus_constant (XEXP (y, 0),
  1183.                              i * GET_MODE_SIZE (SImode))));
  1184.       emit_insn (gen_movsi (protect_from_queue (x1, 1), protect_from_queue (y1, 0)));
  1185.     }
  1186.     }
  1187. #endif
  1188.   else
  1189.     abort ();
  1190. }
  1191.  
  1192. /* Pushing data onto the stack.  */
  1193.  
  1194. /* Push a block of length SIZE (perhaps variable)
  1195.    and return an rtx to address the beginning of the block.
  1196.    Note that it is not possible for the value returned to be a QUEUED.
  1197.    The value may be stack_pointer_rtx.
  1198.  
  1199.    The value we return does take account of STACK_POINTER_OFFSET.  */
  1200.  
  1201. rtx
  1202. push_block (size)
  1203.      rtx size;
  1204. {
  1205.   register rtx temp;
  1206.   if (CONSTANT_P (size) || GET_CODE (size) == REG)
  1207.     anti_adjust_stack (size);
  1208.   else
  1209.     anti_adjust_stack (copy_to_mode_reg (Pmode, size));
  1210.  
  1211. #ifdef STACK_GROWS_DOWNWARD
  1212.   temp = stack_pointer_rtx;
  1213. #else
  1214.   temp = gen_rtx (PLUS, Pmode,
  1215.           stack_pointer_rtx,
  1216.           negate_rtx (Pmode, size));
  1217.   if (GET_CODE (size) != CONST_INT)
  1218.     temp = force_operand (temp, 0);
  1219. #endif
  1220.  
  1221. #ifdef STACK_POINTER_OFFSET
  1222.   temp = plus_constant (temp, STACK_POINTER_OFFSET);
  1223. #endif /* STACK_POINTER_OFFSET */
  1224.  
  1225.   return memory_address (QImode, temp);
  1226. }
  1227.  
  1228. static rtx
  1229. gen_push_operand ()
  1230. {
  1231.   return gen_rtx (
  1232. #ifdef STACK_GROWS_DOWNWARD
  1233.           PRE_DEC,
  1234. #else
  1235.           PRE_INC,
  1236. #endif
  1237.           Pmode,
  1238.           stack_pointer_rtx);
  1239. }
  1240.  
  1241. /* Generate code to push X onto the stack, assuming it has mode MODE.
  1242.    MODE is redundant except when X is a CONST_INT (since they don't
  1243.    carry mode info).
  1244.    SIZE is an rtx for the size of data to be copied (in bytes),
  1245.    needed only if X is BLKmode.
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.    ALIGN (in bytes) is maximum alignment we can assume.
  1252.  
  1253.    If PARTIAL is nonzero, then copy that many of the first words
  1254.    of X into registers starting with REG, and push the rest of X.
  1255.    The amount of space pushed is decreased by PARTIAL words,
  1256.    rounded *down* to a multiple of PARM_BOUNDARY.
  1257.    REG must be a hard register in this case.
  1258.  
  1259.    EXTRA is the amount in bytes of extra space to leave next to this arg.
  1260.  
  1261.    On a machine that lacks real push insns, ARGS_ADDR is the address of
  1262.    the bottom of the argument block for this call.  We use indexing off there
  1263.    to store the arg.  On machines with push insns, ARGS_ADDR is 0.
  1264.  
  1265.    ARGS_SO_FAR is the size of args previously pushed for this call.  */
  1266.  
  1267. static void
  1268. emit_push_insn (x, mode, size, align, partial, reg, extra, args_addr, args_so_far)
  1269.      register rtx x;
  1270.      enum machine_mode mode;
  1271.      rtx size;
  1272.      int align;
  1273.      int partial;
  1274.      rtx reg;
  1275.      int extra;
  1276.      rtx args_addr;
  1277.      rtx args_so_far;
  1278. {
  1279.   rtx xinner;
  1280.   enum direction stack_direction
  1281. #ifdef STACK_GROWS_DOWNWARD
  1282.     = downward;
  1283. #else
  1284.     = upward;
  1285. #endif
  1286.  
  1287.   /* Decide where to pad the argument: `downward' for below,
  1288.      `upward' for above, or `none' for don't pad it.
  1289.      Default is below for small data on big-endian machines; else above.  */
  1290.   enum direction where_pad = FUNCTION_ARG_PADDING (mode, size);
  1291.  
  1292.   xinner = x = protect_from_queue (x, 0);
  1293.  
  1294.   if (extra)
  1295.     {
  1296.       if (args_addr == 0)
  1297.     {
  1298.       /* Push padding now if padding above and stack grows down,
  1299.          or if padding below and stack grows up.  */
  1300.       if (where_pad != none && where_pad != stack_direction)
  1301.         anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra));
  1302.     }
  1303.       else
  1304.     {
  1305.       /* If space already allocated, just adjust the address we use.  */
  1306.       if (where_pad == downward)
  1307.         args_so_far = plus_constant (args_so_far, extra);
  1308.     }
  1309.     }
  1310.  
  1311.   if (mode == BLKmode)
  1312.     {
  1313.       /* Copy a block into the stack, entirely or partially.  */
  1314.  
  1315.       register rtx temp;
  1316.       int used = partial * UNITS_PER_WORD;
  1317.       int offset = used % (PARM_BOUNDARY / BITS_PER_UNIT);
  1318.       int skip;
  1319.       
  1320.       if (size == 0)
  1321.     abort ();
  1322.  
  1323.       used -= offset;
  1324.  
  1325.       /* USED is now the # of bytes we need not copy to the stack
  1326.      because registers will take care of them.  */
  1327.  
  1328.       if (partial != 0)
  1329.     xinner = change_address (xinner, BLKmode,
  1330.                  plus_constant (XEXP (xinner, 0), used));
  1331.  
  1332. /* If the partial register-part of the arg counts in its stack size,
  1333.    skip the part of stack space corresponding to the registers.
  1334.    Otherwise, start copying to the beginning of the stack space,
  1335.    by setting SKIP to 0.  */
  1336. #ifndef FIRST_PARM_CALLER_OFFSET
  1337.       skip = 0;
  1338. #else
  1339.       skip = used;
  1340. #endif
  1341.  
  1342. #ifdef PUSH_ROUNDING
  1343.       /* Do it with several push insns if that doesn't take lots of insns
  1344.      and if there is no difficulty with push insns that skip bytes
  1345.      on the stack for alignment purposes.  */
  1346.       if (args_addr == 0
  1347.       && GET_CODE (size) == CONST_INT
  1348.       && args_addr == 0
  1349.       && skip == 0
  1350.       && (move_by_pieces_ninsns ((unsigned) INTVAL (size) - used, align)
  1351.           < MOVE_RATIO)
  1352.       && PUSH_ROUNDING (INTVAL (size)) == INTVAL (size))
  1353.     move_by_pieces (gen_rtx (MEM, BLKmode, gen_push_operand ()), xinner,
  1354.             INTVAL (size) - used, align);
  1355.       else
  1356. #endif /* PUSH_ROUNDING */
  1357.     {
  1358.       /* Otherwise make space on the stack and copy the data
  1359.          to the address of that space.  */
  1360.  
  1361.       /* Deduct words put into registers from the size we must copy.  */
  1362.       if (partial != 0)
  1363.         {
  1364.           if (GET_CODE (size) == CONST_INT)
  1365.         size = gen_rtx (CONST_INT, VOIDmode, INTVAL (size) - used);
  1366.           else
  1367.         size = expand_binop (GET_MODE (size), sub_optab, size,
  1368.                      gen_rtx (CONST_INT, VOIDmode, used),
  1369.                      0, 0, OPTAB_LIB_WIDEN);
  1370.         }
  1371.  
  1372.       /* Get the address of the stack space.  */
  1373.       if (! args_addr)
  1374.         temp = push_block (size);
  1375.       else if (GET_CODE (args_so_far) == CONST_INT)
  1376.         temp = memory_address (BLKmode,
  1377.                    plus_constant (args_addr,
  1378.                           skip + INTVAL (args_so_far)));
  1379.       else
  1380.         temp = memory_address (BLKmode,
  1381.                    plus_constant (gen_rtx (PLUS, Pmode,
  1382.                                args_addr, args_so_far),
  1383.                           skip));
  1384.  
  1385.       /* TEMP is the address of the block.  Copy the data there.  */
  1386.       if (GET_CODE (size) == CONST_INT
  1387.           && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
  1388.           < MOVE_RATIO))
  1389.         {
  1390.           move_by_pieces (gen_rtx (MEM, BLKmode, temp), xinner,
  1391.                   INTVAL (size), align);
  1392.           goto ret;
  1393.         }
  1394.       /* Try the most limited insn first, because there's no point
  1395.          including more than one in the machine description unless
  1396.          the more limited one has some advantage.  */
  1397. #ifdef HAVE_movstrqi
  1398.       if (HAVE_movstrqi
  1399.           && GET_CODE (size) == CONST_INT
  1400.           && ((unsigned) INTVAL (size)
  1401.           < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
  1402.         {
  1403.           emit_insn (gen_movstrqi (gen_rtx (MEM, BLKmode, temp),
  1404.                        xinner, size,
  1405.                        gen_rtx (CONST_INT, VOIDmode, align)));
  1406.           goto ret;
  1407.         }
  1408. #endif
  1409. #ifdef HAVE_movstrhi
  1410.       if (HAVE_movstrhi
  1411.           && GET_CODE (size) == CONST_INT
  1412.           && ((unsigned) INTVAL (size)
  1413.           < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
  1414.         {
  1415.           emit_insn (gen_movstrhi (gen_rtx (MEM, BLKmode, temp),
  1416.                        xinner, size,
  1417.                        gen_rtx (CONST_INT, VOIDmode, align)));
  1418.           goto ret;
  1419.         }
  1420. #endif
  1421. #ifdef HAVE_movstrsi
  1422.       if (HAVE_movstrsi)
  1423.         {
  1424.           emit_insn (gen_movstrsi (gen_rtx (MEM, BLKmode, temp),
  1425.                        xinner, size,
  1426.                        gen_rtx (CONST_INT, VOIDmode, align)));
  1427.           goto ret;
  1428.         }
  1429. #endif
  1430.  
  1431.       if (reg_mentioned_p (stack_pointer_rtx, temp))
  1432.         {
  1433.           /* Now that emit_library_call does force_operand
  1434.          before pushing anything, preadjustment does not work.  */
  1435.           temp = copy_to_reg (temp);
  1436. #if 0
  1437.           /* Correct TEMP so it holds what will be a description of
  1438.          the address to copy to, valid after one arg is pushed.  */
  1439.           int xsize = GET_MODE_SIZE (Pmode);
  1440. #ifdef PUSH_ROUNDING
  1441.           xsize = PUSH_ROUNDING (xsize);
  1442. #endif
  1443.           xsize = ((xsize + PARM_BOUNDARY / BITS_PER_UNIT - 1)
  1444.                / (PARM_BOUNDARY / BITS_PER_UNIT)
  1445.                * (PARM_BOUNDARY / BITS_PER_UNIT));
  1446. #ifdef TARGET_MEM_FUNCTIONS
  1447.           /* If we are calling bcopy, we push one arg before TEMP.
  1448.          If calling memcpy, we push two.  */
  1449.           xsize *= 2;
  1450. #endif
  1451. #ifdef STACK_GROWS_DOWNWARD
  1452.           temp = plus_constant (temp, xsize);
  1453. #else
  1454.           temp = plus_constant (temp, -xsize);
  1455. #endif /* not STACK_GROWS_DOWNWARD */
  1456. #endif /* 0 */
  1457.         }
  1458.  
  1459.       /* Make inhibit_defer_pop nonzero around the library call
  1460.          to force it to pop the bcopy-arguments right away.  */
  1461.       NO_DEFER_POP;
  1462. #ifdef TARGET_MEM_FUNCTIONS
  1463.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memcpy"), 0,
  1464.                  VOIDmode, 3, temp, Pmode, XEXP (xinner, 0), Pmode,
  1465.                  size, Pmode);
  1466. #else
  1467.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bcopy"), 0,
  1468.                  VOIDmode, 3, XEXP (xinner, 0), Pmode, temp, Pmode,
  1469.                  size, Pmode);
  1470. #endif
  1471.       OK_DEFER_POP;
  1472.     }
  1473.     }
  1474.   else if (partial > 0)
  1475.     {
  1476.       /* Scalar partly in registers.  */
  1477.  
  1478.       int size = GET_MODE_SIZE (mode) / UNITS_PER_WORD;
  1479.       int i;
  1480.       int not_stack;
  1481.       /* # words of start of argument
  1482.      that we must make space for but need not store.  */
  1483.       int offset = partial % (PARM_BOUNDARY / BITS_PER_WORD);
  1484.       int args_offset = INTVAL (args_so_far);
  1485.       int skip;
  1486.  
  1487.       /* If we make space by pushing it, we might as well push
  1488.      the real data.  Otherwise, we can leave OFFSET nonzero
  1489.      and leave the space uninitialized.  */
  1490.       if (args_addr == 0)
  1491.     offset = 0;
  1492.  
  1493.       /* Now NOT_STACK gets the number of words that we don't need to
  1494.      allocate on the stack.  */
  1495.       not_stack = partial - offset;
  1496.  
  1497. /* If the partial register-part of the arg counts in its stack size,
  1498.    skip the part of stack space corresponding to the registers.
  1499.    Otherwise, start copying to the beginning of the stack space,
  1500.    by setting SKIP to 0.  */
  1501. #ifndef FIRST_PARM_CALLER_OFFSET
  1502.       skip = 0;
  1503. #else
  1504.       skip = not_stack;
  1505. #endif
  1506.  
  1507.       if (GET_CODE (x) == CONST_DOUBLE && x != dconst0_rtx)
  1508.     x = force_const_double_mem (x);
  1509.  
  1510.       /* Loop over all the words allocated on the stack for this arg.  */
  1511.       /* We can do it by words, because any scalar bigger than a word
  1512.      has a size a multiple of a word.  */
  1513. #ifdef APPLE_C
  1514.       for (i = (push_args_reversed ? size-1 : not_stack);
  1515.        (push_args_reversed ? (i >= not_stack) : (i < size));
  1516.        (push_args_reversed ? i-- : i++))
  1517. #else
  1518. #ifndef PUSH_ARGS_REVERSED
  1519.       for (i = not_stack; i < size; i++)
  1520. #else
  1521.       for (i = size - 1; i >= not_stack; i--)
  1522. #endif
  1523. #endif /* APPLE_C */
  1524.     if (i >= not_stack + offset)
  1525.       {
  1526.         rtx wd;
  1527.         rtx addr;
  1528.         /* Get the next word of the value in WD.  */
  1529.         if (GET_CODE (x) == MEM)
  1530.           {
  1531.         rtx addr = memory_address (SImode,
  1532.                        plus_constant (XEXP (x, 0),
  1533.                               i * UNITS_PER_WORD));
  1534.         /* Copy to a reg, since machine may lack
  1535.            memory-to-memory move insns.  */
  1536.         wd = copy_to_reg (gen_rtx (MEM, SImode, addr));
  1537.           }
  1538.         else if (GET_CODE (x) == REG)
  1539.           wd = gen_rtx (SUBREG, SImode, x, i);
  1540.         else if (x == dconst0_rtx)
  1541.           wd = const0_rtx;
  1542.         else
  1543.           abort ();
  1544.  
  1545.         emit_push_insn (wd,
  1546.                 SImode, 0, align, 0, 0, 0, args_addr,
  1547.                 gen_rtx (CONST_INT, VOIDmode,
  1548.                      args_offset + (i - not_stack + skip) * UNITS_PER_WORD));
  1549.       }
  1550.     }
  1551.   else
  1552.     {
  1553.       rtx addr;
  1554. #ifdef PUSH_ROUNDING
  1555.       if (args_addr == 0)
  1556.     addr = gen_push_operand ();
  1557.       else
  1558. #endif
  1559.     if (GET_CODE (args_so_far) == CONST_INT)
  1560.       addr
  1561.         = memory_address (mode,
  1562.                   plus_constant (args_addr, INTVAL (args_so_far)));
  1563.       else
  1564.     addr = memory_address (mode, gen_rtx (PLUS, Pmode, args_addr,
  1565.                           args_so_far));
  1566.  
  1567.       emit_move_insn (gen_rtx (MEM, mode, addr), x);
  1568.     }
  1569.  
  1570.  ret:
  1571.   /* If part should go in registers, copy that part
  1572.      into the appropriate registers.  Do this now, at the end,
  1573.      since mem-to-mem copies above may do function calls.  */
  1574.   if (partial > 0)
  1575.     move_block_to_reg (REGNO (reg), x, partial);
  1576.  
  1577.   if (extra && args_addr == 0 && where_pad == stack_direction)
  1578.     anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra));
  1579. }
  1580.  
  1581. /* Output a library call to function FUN (a SYMBOL_REF rtx)
  1582.    (emitting the queue unless NO_QUEUE is nonzero),
  1583.    for a value of mode OUTMODE,
  1584.    with NARGS different arguments, passed as alternating rtx values
  1585.    and machine_modes to convert them to.
  1586.    The rtx values should have been passed through protect_from_queue already.  */
  1587.  
  1588. void
  1589. #ifdef APPLE_HAX
  1590. emit_library_call (fun, no_queue, outmode, nargs)
  1591.      rtx fun;
  1592.      int no_queue;
  1593.      enum machine_mode outmode;
  1594.      int nargs;
  1595. {
  1596.   register va_list p;
  1597.   register int args_size = 0;
  1598.   register int argnum;
  1599. #else
  1600. emit_library_call (va_alist)
  1601.      va_dcl
  1602. {
  1603.   register va_list p;
  1604.   register int args_size = 0;
  1605.   register int argnum;
  1606.   enum machine_mode outmode;
  1607.   int nargs;
  1608.   rtx fun;
  1609. #endif /* APPLE_HAX */
  1610.   rtx orgfun;
  1611.   int inc;
  1612.   int count;
  1613.   rtx *regvec;
  1614.   rtx argblock = 0;
  1615.   CUMULATIVE_ARGS args_so_far;
  1616.   struct arg { rtx value; enum machine_mode mode; };
  1617.   struct arg *argvec;
  1618.   int old_inhibit_defer_pop = inhibit_defer_pop;
  1619.   int stack_padding = 0;
  1620. #ifdef APPLE_HAX
  1621.   rtx use_insns;
  1622.  
  1623.   orgfun = fun;
  1624.   va_start (p, nargs);
  1625. #else
  1626.   int no_queue = 0;
  1627.   rtx use_insns;
  1628.  
  1629.   va_start (p);
  1630.   orgfun = fun = va_arg (p, rtx);
  1631.   no_queue = va_arg (p, int);
  1632.   outmode = va_arg (p, enum machine_mode);
  1633.   nargs = va_arg (p, int);
  1634. #endif /* APPLE_HAX */
  1635.  
  1636. #ifdef APPLE_HAX
  1637.   /* Library calls may need to be imported into this module. */
  1638.   if (GET_CODE (fun) == SYMBOL_REF)
  1639.     import_a_function (XSTR (fun, 0));
  1640. #endif /* APPLE_HAX */
  1641.   regvec = (rtx *) alloca (nargs * sizeof (rtx));
  1642.  
  1643.   /* Copy all the libcall-arguments out of the varargs data
  1644.      and into a vector ARGVEC.  */
  1645.   argvec = (struct arg *) alloca (nargs * sizeof (struct arg));
  1646.   for (count = 0; count < nargs; count++)
  1647.     {
  1648.       rtx val = va_arg (p, rtx);
  1649.       enum machine_mode mode = va_arg (p, enum machine_mode);
  1650.  
  1651.       argvec[count].value = val;
  1652.  
  1653.       /* Convert the arg value to the mode the library wants.
  1654.      Also make sure it is a reasonable operand
  1655.      for a move or push insn.  */
  1656.       /* ??? It is wrong to do it here; must do it earlier
  1657.      where we know the signedness of the arg.  */
  1658.       if (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode)
  1659.     {
  1660.       val = gen_reg_rtx (mode);
  1661.       convert_move (val, argvec[count].value, 0);
  1662.     }
  1663.       else if (GET_CODE (val) != REG && GET_CODE (val) != MEM
  1664.            
  1665.            && ! ((CONSTANT_P (val) || GET_CODE (val) == CONST_DOUBLE)
  1666.              && LEGITIMATE_CONSTANT_P (val)))
  1667.     val = force_operand (val, 0);
  1668.  
  1669.       argvec[count].value = val;
  1670.       argvec[count].mode = mode;
  1671.     }
  1672.   va_end (p);
  1673.  
  1674.   /* If we have no actual push instructions, make space for all the args
  1675.      right now.  */
  1676. #ifndef PUSH_ROUNDING
  1677.   INIT_CUMULATIVE_ARGS (args_so_far, (tree)0, NULL);
  1678.   for (count = 0; count < nargs; count++)
  1679.     {
  1680.       register enum machine_mode mode = argvec[count].mode;
  1681.       register rtx reg;
  1682.       register int partial;
  1683.  
  1684.       reg = FUNCTION_ARG (args_so_far, mode, (tree)0, 1);
  1685. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  1686.       partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, (tree)0, 1);
  1687. #else
  1688.       partial = 0;
  1689. #endif
  1690.       if (reg == 0 || partial != 0)
  1691.     args_size += GET_MODE_SIZE (mode);
  1692.       if (partial != 0)
  1693.     args_size -= partial * GET_MODE_SIZE (SImode);
  1694.       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
  1695.     }
  1696.  
  1697.   if (args_size != 0)
  1698.     {
  1699. #ifdef STACK_ARGS_ADJUST
  1700.       struct args_size size;
  1701.       size.constant = args_size;
  1702.       size.var = 0;
  1703.       STACK_ARGS_ADJUST (size);
  1704.       args_size = size.constant;
  1705. #endif
  1706.       argblock
  1707.     = push_block (round_push (gen_rtx (CONST_INT, VOIDmode, args_size)));
  1708.     }
  1709. #endif /* no PUSH_ROUNDING */
  1710.  
  1711.   INIT_CUMULATIVE_ARGS (args_so_far, (tree)0, NULL);
  1712.  
  1713. #ifdef APPLE_C
  1714.   inc = -1;
  1715.   argnum = nargs - 1;
  1716. #else
  1717. #ifdef PUSH_ARGS_REVERSED
  1718.   inc = -1;
  1719.   argnum = nargs - 1;
  1720. #else
  1721.   inc = 1;
  1722.   argnum = 0;
  1723. #endif
  1724. #endif /* APPLE_C */
  1725.   args_size = stack_padding;
  1726.  
  1727.   for (count = 0; count < nargs; count++, argnum += inc)
  1728.     {
  1729.       register enum machine_mode mode = argvec[argnum].mode;
  1730.       register rtx val = argvec[argnum].value;
  1731.       rtx reg;
  1732.       int partial;
  1733.       int arg_size;
  1734.  
  1735.       reg = FUNCTION_ARG (args_so_far, mode, (tree)0, 1);
  1736.       regvec[argnum] = reg;
  1737. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  1738.       partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, (tree)0, 1);
  1739. #else
  1740.       partial = 0;
  1741. #endif
  1742.  
  1743.       if (reg != 0 && partial == 0)
  1744.     emit_move_insn (reg, val);
  1745.       else
  1746.     emit_push_insn (val, mode, 0, 0, partial, reg, 0, argblock,
  1747.             gen_rtx (CONST_INT, VOIDmode, args_size));
  1748.  
  1749.       /* Compute size of stack space used by this argument.  */
  1750.       if (reg == 0 || partial != 0)
  1751.     arg_size = GET_MODE_SIZE (mode);
  1752.       else
  1753.     arg_size = 0;
  1754.       if (partial != 0)
  1755.     arg_size
  1756.       -= ((partial * UNITS_PER_WORD)
  1757.           / (PARM_BOUNDARY / BITS_PER_UNIT)
  1758.           * (PARM_BOUNDARY / BITS_PER_UNIT));
  1759.  
  1760.       args_size += arg_size;
  1761.       NO_DEFER_POP;
  1762.       FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
  1763.     }
  1764.  
  1765.   /* For version 1.37, try deleting this entirely.  */
  1766.   if (! no_queue)
  1767.     emit_queue ();
  1768.  
  1769.   fun = prepare_call_address (fun, 0);
  1770.  
  1771.   /* Any regs containing parms remain in use through the call.  */
  1772.   start_sequence ();
  1773.   for (count = 0; count < nargs; count++)
  1774.     if (regvec[count] != 0)
  1775.       emit_insn (gen_rtx (USE, VOIDmode, regvec[count]));
  1776.  
  1777.   use_insns = gen_sequence ();
  1778.   end_sequence ();
  1779.  
  1780. #ifdef STACK_BOUNDARY
  1781.   args_size = (args_size + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES;
  1782. #endif
  1783.  
  1784.   /* Don't allow popping to be deferred, since then
  1785.      cse'ing of library calls could delete a call and leave the pop.  */
  1786.   NO_DEFER_POP;
  1787.   emit_call_1 (fun, get_identifier (XSTR (orgfun, 0)), args_size,
  1788.            FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
  1789.            outmode != VOIDmode ? hard_libcall_value (outmode) : 0,
  1790. #ifdef APPLE_C
  1791.            old_inhibit_defer_pop + 1, use_insns, FALSE, VOIDmode, NULL);
  1792. #else
  1793.            old_inhibit_defer_pop + 1, use_insns);
  1794. #endif /* APPLE_C */
  1795.   OK_DEFER_POP;
  1796. }
  1797.  
  1798. /* Expand an assignment that stores the value of FROM into TO.
  1799.    If WANT_VALUE is nonzero, return an rtx for the value of TO.
  1800.    (This may contain a QUEUED rtx.)
  1801.    Otherwise, the returned value is not meaningful.
  1802.  
  1803.    SUGGEST_REG is no longer actually used.
  1804.    It used to mean, copy the value through a register
  1805.    and return that register, if that is possible.
  1806.    But now we do this if WANT_VALUE.
  1807.  
  1808.    If the value stored is a constant, we return the constant.  */
  1809.  
  1810. rtx
  1811. expand_assignment (to, from, want_value, suggest_reg)
  1812.      tree to, from;
  1813.      int want_value;
  1814.      int suggest_reg;
  1815. {
  1816.   register rtx to_rtx = 0;
  1817.  
  1818.   /* Don't crash if the lhs of the assignment was erroneous.  */
  1819.  
  1820.   if (TREE_CODE (to) == ERROR_MARK)
  1821.     return expand_expr (from, 0, VOIDmode, 0);
  1822.  
  1823.   /* Assignment of a structure component needs special treatment
  1824.      if the structure component's rtx is not simply a MEM.
  1825.      Assignment of an array element at a constant index
  1826.      has the same problem.  */
  1827.  
  1828.   if (TREE_CODE (to) == COMPONENT_REF
  1829.       || (TREE_CODE (to) == ARRAY_REF
  1830.       && TREE_CODE (TREE_OPERAND (to, 1)) == INTEGER_CST
  1831.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (to))) == INTEGER_CST))
  1832.     {
  1833.       register enum machine_mode mode1;
  1834.       int bitsize;
  1835.       int volstruct = 0;
  1836.       tree tem = to;
  1837.       int bitpos = 0;
  1838.       int unsignedp;
  1839.  
  1840.       if (TREE_CODE (to) == COMPONENT_REF)
  1841.     {
  1842.       tree field = TREE_OPERAND (to, 1);
  1843.       bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field);
  1844.       mode1 = DECL_MODE (TREE_OPERAND (to, 1));
  1845.       unsignedp = TREE_UNSIGNED (field);
  1846.     }
  1847.       else
  1848.     {
  1849.       mode1 = TYPE_MODE (TREE_TYPE (to));
  1850.       bitsize = GET_MODE_BITSIZE (mode1);
  1851.       unsignedp = TREE_UNSIGNED (TREE_TYPE (to));
  1852.     }
  1853.  
  1854.       /* Compute cumulative bit-offset for nested component-refs
  1855.      and array-refs, and find the ultimate containing object.  */
  1856.  
  1857.       while (1)
  1858.     {
  1859.       if (TREE_CODE (tem) == COMPONENT_REF)
  1860.         {
  1861.           bitpos += DECL_OFFSET (TREE_OPERAND (tem, 1));
  1862.           if (TREE_THIS_VOLATILE (tem))
  1863.         volstruct = 1;
  1864.         }
  1865.       else if (TREE_CODE (tem) == ARRAY_REF
  1866.            && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
  1867.            && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST)
  1868.         {
  1869.           bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))
  1870.              * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem)))
  1871.              * TYPE_SIZE_UNIT (TREE_TYPE (tem)));
  1872.         }
  1873.       else
  1874.         break;
  1875.       tem = TREE_OPERAND (tem, 0);
  1876.     }
  1877.       /* TEM is now the containing data object.  */
  1878.  
  1879.       /* If we are going to use store_bit_field and extract_bit_field,
  1880.      make sure to_rtx will be safe for multiple use.  */
  1881.       if (mode1 == BImode && want_value)
  1882.     tem = stabilize_reference (tem);
  1883.  
  1884.       to_rtx = expand_expr (tem, 0, VOIDmode, 0);
  1885.  
  1886.       return store_field (to_rtx, bitsize, bitpos, mode1, from,
  1887.               (want_value
  1888.                /* Spurious cast makes HPUX compiler happy.  */
  1889.                ? (enum machine_mode) TYPE_MODE (TREE_TYPE (to))
  1890.                : VOIDmode),
  1891.               unsignedp,
  1892.               /* Required alignment of containing datum.  */
  1893.               TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT);
  1894.     }
  1895.  
  1896.   /* Ordinary treatment.  Expand TO to get a REG or MEM rtx.
  1897.      Don't re-expand if it was expanded already (in COMPONENT_REF case).  */
  1898.  
  1899.   if (to_rtx == 0)
  1900.     to_rtx = expand_expr (to, 0, VOIDmode, 0);
  1901.  
  1902.   /* Compute FROM and store the value in the rtx we got.  */
  1903.  
  1904.   return store_expr (from, to_rtx, want_value);
  1905. }
  1906.  
  1907. /* Generate code for computing expression EXP,
  1908.    and storing the value into TARGET.
  1909.    Returns TARGET or an equivalent value.
  1910.    TARGET may contain a QUEUED rtx.
  1911.  
  1912.    If SUGGEST_REG is nonzero, copy the value through a register
  1913.    and return that register, if that is possible.
  1914.  
  1915.    If the value stored is a constant, we return the constant.  */
  1916.  
  1917. rtx
  1918. store_expr (exp, target, suggest_reg)
  1919.      register tree exp;
  1920.      register rtx target;
  1921.      int suggest_reg;
  1922. {
  1923.   register rtx temp;
  1924.   int dont_return_target = 0;
  1925.  
  1926.   /* Copying a non-constant CONSTRUCTOR needs special treatment.  */
  1927.  
  1928.   if (TREE_CODE (exp) == CONSTRUCTOR && ! TREE_LITERAL (exp))
  1929.     {
  1930.       store_constructor (exp, target);
  1931.       return target;
  1932.     }
  1933.  
  1934.   if (suggest_reg && GET_CODE (target) == MEM && GET_MODE (target) != BLKmode)
  1935.     /* If target is in memory and caller wants value in a register instead,
  1936.        arrange that.  Pass TARGET as target for expand_expr so that,
  1937.        if EXP is another assignment, SUGGEST_REG will be nonzero for it.
  1938.        We know expand_expr will not use the target in that case.  */
  1939.     {
  1940.       temp = expand_expr (exp, cse_not_expected ? 0 : target,
  1941.               GET_MODE (target), 0);
  1942.       if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode)
  1943.     temp = copy_to_reg (temp);
  1944.       dont_return_target = 1;
  1945.     }
  1946.   else if (queued_subexp_p (target))
  1947.     /* If target contains a postincrement, it is not safe
  1948.        to use as the returned value.  It would access the wrong
  1949.        place by the time the queued increment gets output.
  1950.        So copy the value through a temporary and use that temp
  1951.        as the result.  */
  1952.     {
  1953.       temp = expand_expr (exp, 0, GET_MODE (target), 0);
  1954.       if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode)
  1955.     temp = copy_to_reg (temp);
  1956.       dont_return_target = 1;
  1957.     }
  1958.   else
  1959.     {
  1960.       temp = expand_expr (exp, target, GET_MODE (target), 0);
  1961.       /* DO return TARGET if it's a specified hardware register.
  1962.      expand_return relies on this.  */
  1963.       if (!(target && GET_CODE (target) == REG
  1964.         && REGNO (target) < FIRST_PSEUDO_REGISTER)
  1965.       && (CONSTANT_P (temp) || GET_CODE (temp) == CONST_DOUBLE))
  1966.     dont_return_target = 1;
  1967.     }
  1968.  
  1969.   /* If value was not generated in the target, store it there.
  1970.      Convert the value to TARGET's type first if nec.  */
  1971.  
  1972.   if (temp != target && TREE_CODE (exp) != ERROR_MARK)
  1973.     {
  1974.       target = protect_from_queue (target, 1);
  1975.       if (GET_MODE (temp) != GET_MODE (target)
  1976.       && GET_MODE (temp) != VOIDmode)
  1977.     {
  1978.       int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  1979.       if (dont_return_target)
  1980.         {
  1981.           /* In this case, we will return TEMP,
  1982.          so make sure it has the proper mode.
  1983.          But don't forget to store the value into TARGET.  */
  1984.           temp = convert_to_mode (GET_MODE (target), temp, unsignedp);
  1985.           emit_move_insn (target, temp);
  1986.         }
  1987.       else
  1988.         convert_move (target, temp, unsignedp);
  1989.     }
  1990.  
  1991.       else if (GET_MODE (temp) == BLKmode)
  1992.     emit_block_move (target, temp, expr_size (exp),
  1993.              TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  1994.       else
  1995.     emit_move_insn (target, temp);
  1996.     }
  1997.   if (dont_return_target)
  1998.     return temp;
  1999.   return target;
  2000. }
  2001.  
  2002. /* Store the value of constructor EXP into the rtx TARGET.
  2003.    TARGET is either a REG or a MEM.  */
  2004.  
  2005. static void
  2006. store_constructor (exp, target)
  2007.      tree exp;
  2008.      rtx target;
  2009. {
  2010.   /* Don't try copying piece by piece into a hard register
  2011.      since that is vulnerable to being clobbered by EXP.
  2012.      Instead, construct in a pseudo register and then copy it all.  */
  2013.   if (GET_CODE (target) == REG && REGNO (target) < FIRST_PSEUDO_REGISTER)
  2014.     {
  2015.       rtx temp = gen_reg_rtx (GET_MODE (target));
  2016.       store_constructor (exp, temp);
  2017.       emit_move_insn (target, temp);
  2018.       return;
  2019.     }
  2020.  
  2021.   if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
  2022.     {
  2023.       register tree elt;
  2024.  
  2025.       /* If the constructor has fewer fields than the structure,
  2026.      clear the whole structure first.  */
  2027.  
  2028.       if (list_length (CONSTRUCTOR_ELTS (exp))
  2029.       != list_length (TYPE_FIELDS (TREE_TYPE (exp))))
  2030.     clear_storage (target, int_size_in_bytes (TREE_TYPE (exp)));
  2031.       else
  2032.     /* Inform later passes that the old value is dead.  */
  2033.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  2034.  
  2035.       /* Store each element of the constructor into
  2036.      the corresponding field of TARGET.  */
  2037.  
  2038.       for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
  2039.     {
  2040.       register tree field = TREE_PURPOSE (elt);
  2041.       register enum machine_mode mode;
  2042.       int bitsize;
  2043.       int bitpos;
  2044.       int unsignedp;
  2045.  
  2046.       bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field);
  2047.       mode = DECL_MODE (field);
  2048.       unsignedp = TREE_UNSIGNED (field);
  2049.  
  2050.       bitpos = DECL_OFFSET (field);
  2051.  
  2052.       store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt),
  2053.                /* The alignment of TARGET is
  2054.               at least what its type requires.  */
  2055.                VOIDmode, 0,
  2056.                TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2057.     }
  2058.     }
  2059.   else if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
  2060.     {
  2061.       register tree elt;
  2062.       register int i;
  2063.       tree domain = TYPE_DOMAIN (TREE_TYPE (exp));
  2064.       int minelt = TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain));
  2065.       int maxelt = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain));
  2066.       tree elttype = TREE_TYPE (TREE_TYPE (exp));
  2067.  
  2068.       /* If the constructor has fewer fields than the structure,
  2069.      clear the whole structure first.  */
  2070.  
  2071.       if (list_length (CONSTRUCTOR_ELTS (exp)) < maxelt - minelt + 1)
  2072.     clear_storage (target, maxelt - minelt + 1);
  2073.       else
  2074.     /* Inform later passes that the old value is dead.  */
  2075.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  2076.  
  2077.       /* Store each element of the constructor into
  2078.      the corresponding element of TARGET, determined
  2079.      by counting the elements.  */
  2080.       for (elt = CONSTRUCTOR_ELTS (exp), i = 0;
  2081.        elt;
  2082.        elt = TREE_CHAIN (elt), i++)
  2083.     {
  2084.       register enum machine_mode mode;
  2085.       int bitsize;
  2086.       int bitpos;
  2087.       int unsignedp;
  2088.  
  2089.       mode = TYPE_MODE (elttype);
  2090.       bitsize = GET_MODE_BITSIZE (mode);
  2091.       unsignedp = TREE_UNSIGNED (elttype);
  2092.  
  2093.       bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype))
  2094.             * TYPE_SIZE_UNIT (elttype));
  2095.  
  2096.       store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt),
  2097.                /* The alignment of TARGET is
  2098.               at least what its type requires.  */
  2099.                VOIDmode, 0,
  2100.                TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  2101.     }
  2102.     }
  2103. }
  2104.  
  2105. /* Store the value of EXP (an expression tree)
  2106.    into a subfield of TARGET which has mode MODE and occupies
  2107.    BITSIZE bits, starting BITPOS bits from the start of TARGET.
  2108.  
  2109.    If VALUE_MODE is VOIDmode, return nothing in particular.
  2110.    UNSIGNEDP is not used in this case.
  2111.  
  2112.    Otherwise, return an rtx for the value stored.  This rtx
  2113.    has mode VALUE_MODE if that is convenient to do.
  2114.    In this case, UNSIGNEDP must be nonzero if the value is an unsigned type.
  2115.  
  2116.    ALIGN is the alignment that TARGET is known to have, measured in bytes.  */
  2117.  
  2118. static rtx
  2119. store_field (target, bitsize, bitpos, mode, exp, value_mode, unsignedp, align)
  2120.      rtx target;
  2121.      int bitsize, bitpos;
  2122.      enum machine_mode mode;
  2123.      tree exp;
  2124.      enum machine_mode value_mode;
  2125.      int unsignedp;
  2126.      int align;
  2127. {
  2128.   /* If the structure is in a register or if the component
  2129.      is a bit field, we cannot use addressing to access it.
  2130.      Use bit-field techniques or SUBREG to store in it.  */
  2131.  
  2132.   if (mode == BImode || GET_CODE (target) == REG
  2133.       || GET_CODE (target) == SUBREG)
  2134.     {
  2135.       store_bit_field (target, bitsize, bitpos,
  2136.                mode,
  2137.                expand_expr (exp, 0, VOIDmode, 0),
  2138.                align);
  2139.       if (value_mode != VOIDmode)
  2140.     return extract_bit_field (target, bitsize, bitpos, unsignedp,
  2141.                   0, value_mode, 0, align);
  2142.       return const0_rtx;
  2143.     }
  2144.   else
  2145.     {
  2146.       rtx addr = XEXP (target, 0);
  2147.       rtx to_rtx;
  2148.  
  2149.       /* If a value is wanted, it must be the lhs;
  2150.      so make the address stable for multiple use.  */
  2151.  
  2152.       if (value_mode != VOIDmode && GET_CODE (addr) != REG
  2153.       && ! CONSTANT_ADDRESS_P (addr))
  2154.     addr = copy_to_reg (addr);
  2155.  
  2156.       /* Now build a reference to just the desired component.  */
  2157.  
  2158.       to_rtx = change_address (target, mode,
  2159.                    plus_constant (addr,
  2160.                           (bitpos / BITS_PER_UNIT)));
  2161.       MEM_IN_STRUCT_P (to_rtx) = 1;
  2162.  
  2163.       return store_expr (exp, to_rtx, value_mode != VOIDmode);
  2164.     }
  2165. }
  2166.  
  2167. /* Given an rtx VALUE that may contain additions and multiplications,
  2168.    return an equivalent value that just refers to a register or memory.
  2169.    This is done by generating instructions to perform the arithmetic
  2170.    and returning a pseudo-register containing the value.  */
  2171.  
  2172. rtx
  2173. force_operand (value, target)
  2174.      rtx value, target;
  2175. {
  2176.   register optab binoptab = 0;
  2177.   register rtx op2;
  2178.   /* Use subtarget as the target for operand 0 of a binary operation.  */
  2179.   register rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  2180.  
  2181.   if (GET_CODE (value) == PLUS)
  2182.     binoptab = add_optab;
  2183.   else if (GET_CODE (value) == MINUS)
  2184.     binoptab = sub_optab;
  2185.   else if (GET_CODE (value) == MULT)
  2186.     {
  2187.       op2 = XEXP (value, 1);
  2188.       if (!CONSTANT_P (op2)
  2189.       && !(GET_CODE (op2) == REG && op2 != subtarget))
  2190.     subtarget = 0;
  2191.       return expand_mult (GET_MODE (value),
  2192.               force_operand (XEXP (value, 0), subtarget),
  2193.               force_operand (op2, 0),
  2194.               target, 0);
  2195.     }
  2196.  
  2197.   if (binoptab)
  2198.     {
  2199.       op2 = XEXP (value, 1);
  2200.       if (!CONSTANT_P (op2)
  2201.       && !(GET_CODE (op2) == REG && op2 != subtarget))
  2202.     subtarget = 0;
  2203.       if (binoptab == sub_optab
  2204.       && GET_CODE (op2) == CONST_INT && INTVAL (op2) < 0)
  2205.     {
  2206.       binoptab = add_optab;
  2207.       op2 = gen_rtx (CONST_INT, VOIDmode, - INTVAL (op2));
  2208.     }
  2209.       return expand_binop (GET_MODE (value), binoptab,
  2210.                force_operand (XEXP (value, 0), subtarget),
  2211.                force_operand (op2, 0),
  2212.                target, 0, OPTAB_LIB_WIDEN);
  2213.       /* We give UNSIGNEP = 0 to expand_binop
  2214.      because the only operations we are expanding here are signed ones.  */
  2215.     }
  2216.   return value;
  2217. }
  2218.  
  2219. /* expand_expr: generate code for computing expression EXP.
  2220.    An rtx for the computed value is returned.  The value is never null.
  2221.    In the case of a void EXP, const0_rtx is returned.
  2222.  
  2223.    The value may be stored in TARGET if TARGET is nonzero.
  2224.    TARGET is just a suggestion; callers must assume that
  2225.    the rtx returned may not be the same as TARGET.
  2226.  
  2227.    If TARGET is CONST0_RTX, it means that the value will be ignored.
  2228.  
  2229.    If TMODE is not VOIDmode, it suggests generating the
  2230.    result in mode TMODE.  But this is done only when convenient.
  2231.    Otherwise, TMODE is ignored and the value generated in its natural mode.
  2232.    TMODE is just a suggestion; callers must assume that
  2233.    the rtx returned may not have mode TMODE.
  2234.  
  2235.    If MODIFIER is EXPAND_SUM then when EXP is an addition
  2236.    we can return an rtx of the form (MULT (REG ...) (CONST_INT ...))
  2237.    or a nest of (PLUS ...) and (MINUS ...) where the terms are
  2238.    products as above, or REG or MEM, or constant.
  2239.    Ordinarily in such cases we would output mul or add instructions
  2240.    and then return a pseudo reg containing the sum.
  2241.  
  2242.    If MODIFIER is EXPAND_CONST_ADDRESS then it is ok to return
  2243.    a MEM rtx whose address is a constant that isn't a legitimate address.  */
  2244.  
  2245. /* Subroutine of expand_expr:
  2246.    save the non-copied parts (LIST) of an expr (LHS), and return a list
  2247.    which can restore these values to their previous values,
  2248.    should something modify their storage.  */
  2249. static tree
  2250. save_noncopied_parts (lhs, list)
  2251.      tree lhs;
  2252.      tree list;
  2253. {
  2254.   tree tail;
  2255.   tree parts = 0;
  2256.  
  2257.   for (tail = list; tail; tail = TREE_CHAIN (tail))
  2258.     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
  2259.       parts = chainon (parts, save_noncopied_parts (TREE_VALUE (tail)));
  2260.     else
  2261.       {
  2262.     tree part = TREE_VALUE (tail);
  2263.     tree part_type = TREE_TYPE (part);
  2264.     parts = tree_cons (save_expr (build_component_ref (lhs, part, parts, 0)),
  2265.                build_nt (RTL_EXPR, 0, (tree) assign_stack_local (TYPE_MODE (part_type), int_size_in_bytes (part_type))),
  2266.                parts);
  2267.     store_expr (TREE_PURPOSE (parts), RTL_EXPR_RTL (TREE_VALUE (parts)), 0);
  2268.       }
  2269.   return parts;
  2270. }
  2271.  
  2272. /* Subroutine of expand_expr:
  2273.    return the target to use when recursively expanding
  2274.    the first operand of an arithmetic operation.  */
  2275.  
  2276. static rtx
  2277. validate_subtarget (subtarget, otherop)
  2278.      rtx subtarget;
  2279.      tree otherop;
  2280. {
  2281.   if (TREE_LITERAL (otherop))
  2282.     return subtarget;
  2283.   if (TREE_CODE (otherop) == VAR_DECL
  2284.       && DECL_RTL (otherop) != subtarget)
  2285.     return subtarget;
  2286.   return 0;
  2287. }
  2288.  
  2289. rtx
  2290. expand_expr (exp, target, tmode, modifier)
  2291.      register tree exp;
  2292.      rtx target;
  2293.      enum machine_mode tmode;
  2294.      enum expand_modifier modifier;
  2295. {
  2296.   register rtx op0, op1, temp;
  2297.   tree type = TREE_TYPE (exp);
  2298.   register enum machine_mode mode = TYPE_MODE (type);
  2299.   register enum tree_code code = TREE_CODE (exp);
  2300.   optab this_optab;
  2301.   int negate_1;
  2302.   /* Use subtarget as the target for operand 0 of a binary operation.  */
  2303.   rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  2304.   rtx original_target = target;
  2305.   int ignore = target == const0_rtx;
  2306.  
  2307.   /* Don't use hard regs as subtargets, because the combiner
  2308.      can only handle pseudo regs.  */
  2309.   if (subtarget && REGNO (subtarget) < FIRST_PSEUDO_REGISTER)
  2310.     subtarget = 0;
  2311.   /* Avoid subtargets inside loops,
  2312.      since they hide some invariant expressions.  */
  2313.   if (optimize && inside_loop ())
  2314.     subtarget = 0;
  2315.  
  2316.   if (ignore) target = 0, original_target = 0;
  2317.  
  2318.   /* If will do cse, generate all results into registers
  2319.      since 1) that allows cse to find more things
  2320.      and 2) otherwise cse could produce an insn the machine
  2321.      cannot support.  */
  2322.  
  2323.   if (! cse_not_expected && mode != BLKmode)
  2324.     target = subtarget;
  2325.  
  2326.   /* No sense saving up arithmetic to be done
  2327.      if it's all in the wrong mode to form part of an address.
  2328.      And force_operand won't know whether to sign-extend or zero-extend.  */
  2329.  
  2330.   if (mode != Pmode && modifier == EXPAND_SUM)
  2331.     modifier = EXPAND_NORMAL;
  2332.  
  2333.   switch (code)
  2334.     {
  2335.     case PARM_DECL:
  2336.       if (DECL_RTL (exp) == 0)
  2337.     {
  2338.       error_with_decl (exp, "prior parameter's size depends on `%s'");
  2339.       return const0_rtx;
  2340.     }
  2341.  
  2342.     case FUNCTION_DECL:
  2343.     case VAR_DECL:
  2344.     case RESULT_DECL:
  2345.       if (DECL_RTL (exp) == 0)
  2346.     abort ();
  2347.       /* This is the case of an array whose size is to be determined
  2348.      from its initializer, while the initializer is still being parsed.
  2349.      See expand_decl.  */
  2350.       if (GET_CODE (DECL_RTL (exp)) == MEM
  2351.       && GET_CODE (XEXP (DECL_RTL (exp), 0)) == REG)
  2352.     return change_address (DECL_RTL (exp), GET_MODE (DECL_RTL (exp)),
  2353.                    XEXP (DECL_RTL (exp), 0));
  2354.       if (GET_CODE (DECL_RTL (exp)) == MEM
  2355.       && modifier != EXPAND_CONST_ADDRESS)
  2356.     {
  2357.       /* DECL_RTL probably contains a constant address.
  2358.          On RISC machines where a constant address isn't valid,
  2359.          make some insns to get that address into a register.  */
  2360.       if (!memory_address_p (DECL_MODE (exp), XEXP (DECL_RTL (exp), 0))
  2361.           || (flag_force_addr
  2362.           && CONSTANT_ADDRESS_P (XEXP (DECL_RTL (exp), 0))))
  2363.         return change_address (DECL_RTL (exp), VOIDmode,
  2364.                    copy_rtx (XEXP (DECL_RTL (exp), 0)));
  2365.     }
  2366.       return DECL_RTL (exp);
  2367.  
  2368.     case INTEGER_CST:
  2369.       if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_INT)
  2370.     return gen_rtx (CONST_INT, VOIDmode, TREE_INT_CST_LOW (exp));
  2371.       /* Generate immediate CONST_DOUBLE
  2372.      which will be turned into memory by reload if necessary.  */
  2373.       return immed_double_const (TREE_INT_CST_LOW (exp),
  2374.                  TREE_INT_CST_HIGH (exp),
  2375.                  mode);
  2376.  
  2377.     case CONST_DECL:
  2378.       return expand_expr (DECL_INITIAL (exp), target, VOIDmode, 0);
  2379.  
  2380.     case REAL_CST:
  2381.       /* If optimized, generate immediate CONST_DOUBLE
  2382.      which will be turned into memory by reload if necessary.  */
  2383.       if (!cse_not_expected)
  2384.     return immed_real_const (exp);
  2385.     case COMPLEX_CST:
  2386.     case STRING_CST:
  2387.       if (! TREE_CST_RTL (exp))
  2388.     output_constant_def (exp);
  2389.  
  2390.       /* TREE_CST_RTL probably contains a constant address.
  2391.      On RISC machines where a constant address isn't valid,
  2392.      make some insns to get that address into a register.  */
  2393.       if (GET_CODE (TREE_CST_RTL (exp)) == MEM
  2394.       && modifier != EXPAND_CONST_ADDRESS
  2395.       && !memory_address_p (mode, XEXP (TREE_CST_RTL (exp), 0)))
  2396.     return change_address (TREE_CST_RTL (exp), VOIDmode,
  2397.                    copy_rtx (XEXP (TREE_CST_RTL (exp), 0)));
  2398.       return TREE_CST_RTL (exp);
  2399.  
  2400.     case SAVE_EXPR:
  2401.       if (SAVE_EXPR_RTL (exp) == 0)
  2402.     {
  2403.       rtx reg = gen_reg_rtx (mode);
  2404.       SAVE_EXPR_RTL (exp) = reg;
  2405.       store_expr (TREE_OPERAND (exp, 0), reg, 0);
  2406.       if (!optimize)
  2407.         save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, reg,
  2408.                       save_expr_regs);
  2409.     }
  2410.       /* Don't let the same rtl node appear in two places.  */
  2411.       return SAVE_EXPR_RTL (exp);
  2412.  
  2413.     case LET_STMT:
  2414.       TREE_USED (exp) = 1;
  2415.       temp = expand_expr (STMT_BODY (exp), target, tmode, modifier);
  2416.       return temp;
  2417.  
  2418.     case RTL_EXPR:
  2419.       if (RTL_EXPR_SEQUENCE (exp) == const0_rtx)
  2420.     abort ();
  2421.       emit_insns (RTL_EXPR_SEQUENCE (exp));
  2422.       RTL_EXPR_SEQUENCE (exp) = const0_rtx;
  2423.       return RTL_EXPR_RTL (exp);
  2424.  
  2425.     case CONSTRUCTOR:
  2426.       /* All elts simple constants => refer to a constant in memory.  */
  2427.       if (TREE_STATIC (exp))
  2428.     /* For aggregate types with non-BLKmode modes,
  2429.        this should ideally construct a CONST_INT.  */
  2430.     {
  2431.       rtx constructor = output_constant_def (exp);
  2432.       if (! memory_address_p (GET_MODE (constructor),
  2433.                   XEXP (constructor, 0)))
  2434.         constructor = change_address (constructor, VOIDmode,
  2435.                       XEXP (constructor, 0));
  2436.       return constructor;
  2437.     }
  2438.  
  2439.       if (ignore)
  2440.     {
  2441.       tree elt;
  2442.       for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
  2443.         expand_expr (TREE_VALUE (elt), const0_rtx, VOIDmode, 0);
  2444.       return const0_rtx;
  2445.     }
  2446.       else
  2447.     {
  2448.       if (target == 0)
  2449.         target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
  2450.                   get_structure_value_addr (expr_size (exp)));
  2451.       store_expr (exp, target, 0);
  2452.       return target;
  2453.     }
  2454.  
  2455.     case INDIRECT_REF:
  2456.       {
  2457.     tree exp1 = TREE_OPERAND (exp, 0);
  2458.     tree exp2;
  2459.  
  2460.     /* A SAVE_EXPR as the address in an INDIRECT_EXPR is generated
  2461.        for  *PTR += ANYTHING  where PTR is put inside the SAVE_EXPR.
  2462.        This code has the same general effect as simply doing
  2463.        expand_expr on the save expr, except that the expression PTR
  2464.        is computed for use as a memory address.  This means different
  2465.        code, suitable for indexing, may be generated.  */
  2466.     if (TREE_CODE (exp1) == SAVE_EXPR
  2467.         && SAVE_EXPR_RTL (exp1) == 0
  2468.         && TREE_CODE (exp2 = TREE_OPERAND (exp1, 0)) != ERROR_MARK
  2469.         && TYPE_MODE (TREE_TYPE (exp1)) == Pmode
  2470.         && TYPE_MODE (TREE_TYPE (exp2)) == Pmode)
  2471.       {
  2472.         temp = expand_expr (TREE_OPERAND (exp1, 0), 0, VOIDmode, EXPAND_SUM);
  2473.         op0 = memory_address (mode, temp);
  2474.         op0 = copy_all_regs (op0);
  2475.         SAVE_EXPR_RTL (exp1) = op0;
  2476.       }
  2477.     else
  2478.       {
  2479.         op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, EXPAND_SUM);
  2480.         op0 = memory_address (mode, op0);
  2481.       }
  2482.       }
  2483.       temp = gen_rtx (MEM, mode, op0);
  2484.       /* If address was computed by addition,
  2485.      mark this as an element of an aggregate.  */
  2486.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == PLUS_EXPR
  2487.       || (TREE_CODE (TREE_OPERAND (exp, 0)) == SAVE_EXPR
  2488.           && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == PLUS_EXPR))
  2489.     MEM_IN_STRUCT_P (temp) = 1;
  2490.       MEM_VOLATILE_P (temp) = TREE_THIS_VOLATILE (exp) || flag_volatile;
  2491.       RTX_UNCHANGING_P (temp) = TREE_READONLY (exp);
  2492.       return temp;
  2493.  
  2494.     case ARRAY_REF:
  2495.       if (TREE_CODE (TREE_OPERAND (exp, 1)) != INTEGER_CST
  2496.       || TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST)
  2497.     {
  2498.       /* Nonconstant array index or nonconstant element size.
  2499.          Generate the tree for *(&array+index) and expand that,
  2500.          except do it in a language-independent way
  2501.          and don't complain about non-lvalue arrays.
  2502.          `mark_addressable' should already have been called
  2503.          for any array for which this case will be reached.  */
  2504.  
  2505.       tree array_adr = build (ADDR_EXPR, TYPE_POINTER_TO (type),
  2506.                   TREE_OPERAND (exp, 0));
  2507.       tree index = TREE_OPERAND (exp, 1);
  2508.       tree elt;
  2509.  
  2510.       /* Convert the integer argument to a type the same size as a pointer
  2511.          so the multiply won't overflow spuriously.  */
  2512.       if (TYPE_PRECISION (TREE_TYPE (index)) != POINTER_SIZE)
  2513.         index = convert (type_for_size (POINTER_SIZE, 0), index);
  2514.  
  2515.       /* The array address isn't volatile even if the array is.  */
  2516.       TREE_VOLATILE (array_adr) = 0;
  2517.  
  2518.       elt = build (INDIRECT_REF, type,
  2519.                fold (build (PLUS_EXPR, TYPE_POINTER_TO (type),
  2520.                     array_adr,
  2521.                     fold (build (MULT_EXPR,
  2522.                          TYPE_POINTER_TO (type),
  2523.                          index, size_in_bytes (type))))));
  2524.  
  2525.       return expand_expr (elt, target, tmode, modifier);
  2526.     }
  2527.  
  2528.       /* Fold an expression like: "foo"[2].
  2529.      This is not done in fold so it won't happen inside &.  */
  2530.       {
  2531.     int i;
  2532.     tree arg0 = TREE_OPERAND (exp, 0);
  2533.     tree arg1 = TREE_OPERAND (exp, 1);
  2534.  
  2535.     if (TREE_CODE (arg0) == STRING_CST
  2536.         && TREE_CODE (arg1) == INTEGER_CST
  2537.         && !TREE_INT_CST_HIGH (arg1)
  2538.         && (i = TREE_INT_CST_LOW (arg1)) < TREE_STRING_LENGTH (arg0))
  2539.       {
  2540.         if (TREE_TYPE (TREE_TYPE (arg0)) == integer_type_node)
  2541.           {
  2542.         exp = build_int_2 (((int *)TREE_STRING_POINTER (arg0))[i], 0);
  2543.         TREE_TYPE (exp) = integer_type_node;
  2544.         return expand_expr (exp, target, tmode, modifier);
  2545.           }
  2546.         if (TREE_TYPE (TREE_TYPE (arg0)) == char_type_node)
  2547.           {
  2548.         exp = build_int_2 (TREE_STRING_POINTER (arg0)[i], 0);
  2549.         TREE_TYPE (exp) = integer_type_node;
  2550.         return expand_expr (convert (TREE_TYPE (TREE_TYPE (arg0)), exp), target, tmode, modifier);
  2551.           }
  2552.       }
  2553.       }
  2554.  
  2555.       /* If this is a constant index into a constant array,
  2556.      just get the value from the array.  */
  2557.       if (TREE_READONLY (TREE_OPERAND (exp, 0))
  2558.       && ! TREE_VOLATILE (TREE_OPERAND (exp, 0))
  2559.       && TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == ARRAY_TYPE
  2560.       && TREE_LITERAL (TREE_OPERAND (exp, 1))
  2561.       && TREE_CODE (TREE_OPERAND (exp, 0)) == VAR_DECL
  2562.       && DECL_INITIAL (TREE_OPERAND (exp, 0))
  2563.       && TREE_CODE (DECL_INITIAL (TREE_OPERAND (exp, 0))) != ERROR_MARK)
  2564.     {
  2565.       tree index = fold (TREE_OPERAND (exp, 1));
  2566.       if (TREE_CODE (index) == INTEGER_CST)
  2567.         {
  2568.           int i = TREE_INT_CST_LOW (index);
  2569.           tree init = CONSTRUCTOR_ELTS (DECL_INITIAL (TREE_OPERAND (exp, 0)));
  2570.  
  2571.           while (init && i--)
  2572.         init = TREE_CHAIN (init);
  2573.           if (init)
  2574.         return expand_expr (fold (TREE_VALUE (init)), target, tmode, modifier);
  2575.         }
  2576.     }
  2577.       /* Treat array-ref with constant index as a component-ref.  */
  2578.  
  2579.     case COMPONENT_REF:
  2580.       {
  2581.     register enum machine_mode mode1;
  2582.     int volstruct = 0;
  2583.     int bitsize;
  2584.     tree tem = exp;
  2585.     int bitpos = 0;
  2586.     int unsignedp;
  2587.  
  2588.     if (TREE_CODE (exp) == COMPONENT_REF)
  2589.       {
  2590.         tree field = TREE_OPERAND (exp, 1);
  2591.         bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field);
  2592.         mode1 = DECL_MODE (TREE_OPERAND (exp, 1));
  2593.         unsignedp = TREE_UNSIGNED (field);
  2594.       }
  2595.     else
  2596.       {
  2597.         mode1 = TYPE_MODE (TREE_TYPE (exp));
  2598.         bitsize = GET_MODE_BITSIZE (mode1);
  2599.         unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  2600.       }
  2601.  
  2602.     /* Compute cumulative bit-offset for nested component-refs
  2603.        and array-refs, and find the ultimate containing object.  */
  2604.  
  2605.     while (1)
  2606.       {
  2607.         if (TREE_CODE (tem) == COMPONENT_REF)
  2608.           {
  2609.         bitpos += DECL_OFFSET (TREE_OPERAND (tem, 1));
  2610.         if (TREE_THIS_VOLATILE (tem))
  2611.           volstruct = 1;
  2612.           }
  2613.         else if (TREE_CODE (tem) == ARRAY_REF
  2614.              && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
  2615.              && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST)
  2616.           {
  2617.         bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))
  2618.                * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem)))
  2619.                * TYPE_SIZE_UNIT (TREE_TYPE (tem)));
  2620.           }
  2621.         else
  2622.           break;
  2623.         tem = TREE_OPERAND (tem, 0);
  2624.       }
  2625.  
  2626.     op0 = expand_expr (tem, 0, VOIDmode,
  2627.                (modifier == EXPAND_CONST_ADDRESS
  2628.                 ? modifier : EXPAND_NORMAL));
  2629.  
  2630.     if (mode1 == BImode || GET_CODE (op0) == REG
  2631.         || GET_CODE (op0) == SUBREG)
  2632.       return extract_bit_field (op0, bitsize, bitpos, unsignedp,
  2633.                     target, mode, tmode,
  2634.                     TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT);
  2635.     /* Get a reference to just this component.  */
  2636.     if (modifier == EXPAND_CONST_ADDRESS)
  2637.       op0 = gen_rtx (MEM, mode1, plus_constant (XEXP (op0, 0),
  2638.                             (bitpos / BITS_PER_UNIT)));
  2639.     else
  2640.       op0 = change_address (op0, mode1,
  2641.                 plus_constant (XEXP (op0, 0),
  2642.                            (bitpos / BITS_PER_UNIT)));
  2643.     MEM_IN_STRUCT_P (op0) = 1;
  2644.     MEM_VOLATILE_P (op0) |= volstruct;
  2645.     /* If OP0 is in the shared structure-value stack slot,
  2646.        and it is not BLKmode, copy it into a register.
  2647.        The shared slot may be clobbered at any time by another call.
  2648.        BLKmode is safe because our caller will either copy the value away
  2649.        or take another component and come back here.  */
  2650.     if (mode != BLKmode
  2651.         && TREE_CODE (TREE_OPERAND (exp, 0)) == CALL_EXPR
  2652.         && TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == BLKmode)
  2653.       op0 = copy_to_reg (op0);
  2654.     if (mode == mode1 || mode1 == BLKmode || mode1 == tmode)
  2655.       return op0;
  2656.     if (target == 0)
  2657.       target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  2658.     convert_move (target, op0, unsignedp);
  2659.     return target;
  2660.       }
  2661.  
  2662.       /* Intended for a reference to a buffer of a file-object in Pascal.
  2663.      But it's not certain that a special tree code will really be
  2664.      necessary for these.  INDIRECT_REF might work for them.  */
  2665.     case BUFFER_REF:
  2666.       abort ();
  2667.  
  2668.     case WITH_CLEANUP_EXPR:
  2669.       RTL_EXPR_RTL (TREE_OPERAND (exp, 1))
  2670.     = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
  2671.       cleanups_of_this_call = tree_cons (0, TREE_OPERAND (exp, 2), cleanups_of_this_call);
  2672.       return RTL_EXPR_RTL (TREE_OPERAND (exp, 1));
  2673.  
  2674.     case CALL_EXPR:
  2675.       /* Check for a built-in function.  */
  2676.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
  2677.       && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == FUNCTION_DECL
  2678.       && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
  2679.           != NOT_BUILT_IN))
  2680.     return expand_builtin (exp, target, subtarget, tmode, ignore);
  2681.       /* If this call was expanded already by preexpand_calls,
  2682.      just return the result we got.  */
  2683.       if (CALL_EXPR_RTL (exp) != 0)
  2684.     return CALL_EXPR_RTL (exp);
  2685.       return expand_call (exp, target, ignore);
  2686.  
  2687.     case NOP_EXPR:
  2688.     case CONVERT_EXPR:
  2689.     case REFERENCE_EXPR:
  2690.       if (TREE_CODE (type) == VOID_TYPE || ignore)
  2691.     {
  2692.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, modifier);
  2693.       return const0_rtx;
  2694.     }
  2695.       if (mode == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  2696.     return expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, modifier);
  2697.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, mode, 0);
  2698.       if (GET_MODE (op0) == mode || GET_MODE (op0) == VOIDmode)
  2699.     return op0;
  2700.       if (flag_force_mem && GET_CODE (op0) == MEM)
  2701.     op0 = copy_to_reg (op0);
  2702.       if (GET_MODE (op0) == VOIDmode)
  2703.     /* Avoid problem in convert_move due to unknown mode of OP0.  */
  2704.     op0 = copy_to_mode_reg (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  2705.                 op0);
  2706.       if (target == 0)
  2707.     target = gen_reg_rtx (mode);
  2708.       convert_move (target, op0, TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  2709.       return target;
  2710.  
  2711.     case PLUS_EXPR:
  2712.       preexpand_calls (exp);
  2713.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST
  2714.       && modifier == EXPAND_SUM)
  2715.     {
  2716.       op1 = expand_expr (TREE_OPERAND (exp, 1), subtarget, VOIDmode, EXPAND_SUM);
  2717.       op1 = plus_constant (op1, TREE_INT_CST_LOW (TREE_OPERAND (exp, 0)));
  2718.       return op1;
  2719.     }
  2720.       negate_1 = 1;
  2721.     plus_minus:
  2722.       if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  2723.       && modifier == EXPAND_SUM)
  2724.     {
  2725.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
  2726.       op0 = plus_constant (op0,
  2727.                    negate_1 * TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)));
  2728.       return op0;
  2729.     }
  2730.       this_optab = add_optab;
  2731.       if (modifier != EXPAND_SUM) goto binop;
  2732.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2733.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
  2734.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, EXPAND_SUM);
  2735.       /* Put a sum last, to simplify what follows.  */
  2736. #ifdef OLD_INDEXING
  2737.       if (GET_CODE (op1) == MULT)
  2738.     {
  2739.       temp = op0;
  2740.       op0 = op1;
  2741.       op1 = temp;
  2742.     }
  2743. #endif
  2744. #ifndef OLD_INDEXING
  2745.       /* Make sure any term that's a sum with a constant comes last.  */
  2746.       if (GET_CODE (op0) == PLUS
  2747.       && CONSTANT_P (XEXP (op0, 1)))
  2748.     {
  2749.       temp = op0;
  2750.       op0 = op1;
  2751.       op1 = temp;
  2752.     }
  2753.       /* If adding to a sum including a constant,
  2754.      associate it to put the constant outside.  */
  2755.       if (GET_CODE (op1) == PLUS
  2756.       && CONSTANT_P (XEXP (op1, 1)))
  2757.     {
  2758.       rtx tem;
  2759.       int constant_term = 0;
  2760.  
  2761.       op0 = gen_rtx (PLUS, mode, XEXP (op1, 0), op0);
  2762.       /* Let's also eliminate constants from op0 if possible.  */
  2763.       tem = eliminate_constant_term (op0, &constant_term);
  2764.       if (GET_CODE (XEXP (op1, 1)) == CONST_INT)
  2765.         {
  2766.           if (constant_term != 0)
  2767.         return plus_constant (tem, INTVAL (XEXP (op1, 1)) + constant_term);
  2768.           else
  2769.         return plus_constant (op0, INTVAL (XEXP (op1, 1)));
  2770.         }
  2771.       else
  2772.         return gen_rtx (PLUS, mode, op0, XEXP (op1, 1));
  2773.     }
  2774. #endif
  2775.       return gen_rtx (PLUS, mode, op0, op1);
  2776.  
  2777.     case MINUS_EXPR:
  2778.       preexpand_calls (exp);
  2779.       if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  2780.       && GET_MODE_BITSIZE (TYPE_MODE (type)) <= HOST_BITS_PER_INT)
  2781.     {
  2782.       int negated;
  2783.       if (modifier == EXPAND_SUM)
  2784.         {
  2785.           negate_1 = -1;
  2786.           goto plus_minus;
  2787.         }
  2788.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2789.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2790.       negated = - TREE_INT_CST_LOW (TREE_OPERAND (exp, 1));
  2791.       if (GET_MODE_BITSIZE (mode) < HOST_BITS_PER_INT)
  2792.         negated &= (1 << GET_MODE_BITSIZE (mode)) - 1;
  2793.       op1 = gen_rtx (CONST_INT, VOIDmode, negated);
  2794.       this_optab = add_optab;
  2795.       goto binop2;
  2796.     }
  2797.       this_optab = sub_optab;
  2798.       goto binop;
  2799.  
  2800.     case MULT_EXPR:
  2801.       preexpand_calls (exp);
  2802.       /* If first operand is constant, swap them.
  2803.      Thus the following special case checks need only
  2804.      check the second operand.  */
  2805.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST)
  2806.     {
  2807.       register tree t1 = TREE_OPERAND (exp, 0);
  2808.       TREE_OPERAND (exp, 0) = TREE_OPERAND (exp, 1);
  2809.       TREE_OPERAND (exp, 1) = t1;
  2810.     }
  2811.  
  2812.       /* Attempt to return something suitable for generating an
  2813.      indexed address, for machines that support that.  */
  2814.  
  2815.       if (modifier == EXPAND_SUM
  2816.       && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  2817.     {
  2818.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
  2819.  
  2820.       /* Apply distributive law if OP0 is x+c.  */
  2821.       if (GET_CODE (op0) == PLUS
  2822.           && GET_CODE (XEXP (op0, 1)) == CONST_INT)
  2823.         return gen_rtx (PLUS, mode,
  2824.                 gen_rtx (MULT, mode, XEXP (op0, 0),
  2825.                      gen_rtx (CONST_INT, VOIDmode,
  2826.                           TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))),
  2827.                 gen_rtx (CONST_INT, VOIDmode,
  2828.                      (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))
  2829.                       * INTVAL (XEXP (op0, 1)))));
  2830.  
  2831.       if (GET_CODE (op0) != REG)
  2832.         op0 = force_operand (op0, 0);
  2833.       if (GET_CODE (op0) != REG)
  2834.         op0 = copy_to_mode_reg (mode, op0);
  2835.  
  2836.       return gen_rtx (MULT, mode, op0,
  2837.               gen_rtx (CONST_INT, VOIDmode,
  2838.                    TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))));
  2839.     }
  2840.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2841.       /* Check for multiplying things that have been extended
  2842.      from a narrower type.  If this machine supports multiplying
  2843.      in that narrower type with a result in the desired type,
  2844.      do it that way, and avoid the explicit type-conversion.  */
  2845.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == NOP_EXPR
  2846.       && TREE_CODE (TREE_TYPE (exp)) == INTEGER_TYPE
  2847.       && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  2848.           < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0))))
  2849.       && ((TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  2850.            && int_fits_type_p (TREE_OPERAND (exp, 1),
  2851.                    TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  2852.            /* Don't use a widening multiply if a shift will do.  */
  2853.            && exact_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))) < 0)
  2854.           ||
  2855.           (TREE_CODE (TREE_OPERAND (exp, 1)) == NOP_EXPR
  2856.            && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
  2857.            ==
  2858.            TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))))
  2859.            /* If both operands are extended, they must either both
  2860.           be zero-extended or both be sign-extended.  */
  2861.            && (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
  2862.            ==
  2863.            TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))))))
  2864.     {
  2865.       enum machine_mode innermode
  2866.         = TYPE_MODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)));
  2867.       this_optab = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  2868.             ? umul_widen_optab : smul_widen_optab);
  2869.       if (mode == GET_MODE_WIDER_MODE (innermode)
  2870.           && this_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  2871.         {
  2872.           op0 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  2873.                  0, VOIDmode, 0);
  2874.           if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  2875.         op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  2876.           else
  2877.         op1 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 1), 0),
  2878.                    0, VOIDmode, 0);
  2879.           goto binop2;
  2880.         }
  2881.     }
  2882.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2883.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  2884.       return expand_mult (mode, op0, op1, target, TREE_UNSIGNED (type));
  2885.  
  2886.     case TRUNC_DIV_EXPR:
  2887.     case FLOOR_DIV_EXPR:
  2888.     case CEIL_DIV_EXPR:
  2889.     case ROUND_DIV_EXPR:
  2890.     case EXACT_DIV_EXPR:
  2891.       preexpand_calls (exp);
  2892.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2893.       /* Possible optimization: compute the dividend with EXPAND_SUM
  2894.      then if the divisor is constant can optimize the case
  2895.      where some terms of the dividend have coeffs divisible by it.  */
  2896.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2897.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  2898.       return expand_divmod (0, code, mode, op0, op1, target,
  2899.                 TREE_UNSIGNED (type));
  2900.  
  2901.     case RDIV_EXPR:
  2902.       preexpand_calls (exp);
  2903.       this_optab = flodiv_optab;
  2904.       goto binop;
  2905.  
  2906.     case TRUNC_MOD_EXPR:
  2907.     case FLOOR_MOD_EXPR:
  2908.     case CEIL_MOD_EXPR:
  2909.     case ROUND_MOD_EXPR:
  2910.       preexpand_calls (exp);
  2911.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2912.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2913.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  2914.       return expand_divmod (1, code, mode, op0, op1, target,
  2915.                 TREE_UNSIGNED (type));
  2916. #if 0
  2917. #ifdef HAVE_divmoddisi4
  2918.       if (GET_MODE (op0) != DImode)
  2919.     {
  2920.       temp = gen_reg_rtx (DImode);
  2921.       convert_move (temp, op0, 0);
  2922.       op0 = temp;
  2923.       if (GET_MODE (op1) != SImode && GET_CODE (op1) != CONST_INT)
  2924.         {
  2925.           temp = gen_reg_rtx (SImode);
  2926.           convert_move (temp, op1, 0);
  2927.           op1 = temp;
  2928.         }
  2929.       temp = gen_reg_rtx (SImode);
  2930.       if (target == 0)
  2931.         target = gen_reg_rtx (SImode);
  2932.       emit_insn (gen_divmoddisi4 (temp, protect_from_queue (op0, 0),
  2933.                       protect_from_queue (op1, 0),
  2934.                       protect_from_queue (target, 1)));
  2935.       return target;
  2936.     }
  2937. #endif
  2938. #endif
  2939.  
  2940.     case FIX_ROUND_EXPR:
  2941.     case FIX_FLOOR_EXPR:
  2942.     case FIX_CEIL_EXPR:
  2943.       abort ();            /* Not used for C.  */
  2944.  
  2945.     case FIX_TRUNC_EXPR:
  2946.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  2947.       if (target == 0)
  2948.     target = gen_reg_rtx (mode);
  2949.       {
  2950.     int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  2951.     if (mode == HImode || mode == QImode)
  2952.       {
  2953.         register rtx temp = gen_reg_rtx (SImode);
  2954.         expand_fix (temp, op0, 0);
  2955.         convert_move (target, temp, 0);
  2956.       }
  2957.     else
  2958.       expand_fix (target, op0, unsignedp);
  2959.       }
  2960.       return target;
  2961.  
  2962.     case FLOAT_EXPR:
  2963.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  2964.       if (target == 0)
  2965.     target = gen_reg_rtx (mode);
  2966.       if (GET_MODE (op0) == VOIDmode)
  2967.     /* Avoid problem in convert_move due to unknown mode of OP0.  */
  2968.     op0 = copy_to_mode_reg (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
  2969.                 op0);
  2970.       {
  2971.     int unsignedp = TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)));
  2972.     if (GET_MODE (op0) == HImode
  2973.         || GET_MODE (op0) == QImode)
  2974.       {
  2975.         register rtx temp = gen_reg_rtx (SImode);
  2976.         convert_move (temp, op0, unsignedp);
  2977.         expand_float (target, temp, 0);
  2978.       }
  2979.     else
  2980.       expand_float (target, op0, unsignedp);
  2981.       }
  2982.       return target;
  2983.  
  2984.     case NEGATE_EXPR:
  2985.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  2986.       temp = expand_unop (mode, neg_optab, op0, target, 0);
  2987.       if (temp == 0)
  2988.     abort ();
  2989.       return temp;
  2990.  
  2991.     case ABS_EXPR:
  2992.       /* First try to do it with a special abs instruction.
  2993.      If that does not win, use conditional jump and negate.  */
  2994.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2995.       temp = expand_unop (mode, abs_optab, op0, target, 0);
  2996.       if (temp != 0)
  2997.     return temp;
  2998.       temp = gen_label_rtx ();
  2999.       if (target == 0 || GET_CODE (target) != REG)
  3000.     target = gen_reg_rtx (mode);
  3001.       emit_move_insn (target, op0);
  3002.       emit_cmp_insn (target,
  3003.              expand_expr (convert (TREE_TYPE (exp), integer_zero_node),
  3004.                   0, VOIDmode, 0),
  3005.              0, 0, 0);
  3006.       NO_DEFER_POP;
  3007.       emit_jump_insn (gen_bge (temp));
  3008.       op0 = expand_unop (mode, neg_optab, target, target, 0);
  3009.       if (op0 != target)
  3010.     emit_move_insn (target, op0);
  3011.       emit_label (temp);
  3012.       OK_DEFER_POP;
  3013.       return target;
  3014.  
  3015.     case MAX_EXPR:
  3016.     case MIN_EXPR:
  3017.       mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 1)));
  3018.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  3019.       if (target == 0 || GET_CODE (target) != REG || target == op1)
  3020.     target = gen_reg_rtx (mode);
  3021.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  3022.       if (target != op0)
  3023.     emit_move_insn (target, op0);
  3024.       op0 = gen_label_rtx ();
  3025.       if (code == MAX_EXPR)
  3026.     temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
  3027.         ? compare1 (target, op1, GEU, LEU, 1, mode)
  3028.         : compare1 (target, op1, GE, LE, 0, mode));
  3029.       else
  3030.     temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
  3031.         ? compare1 (target, op1, LEU, GEU, 1, mode)
  3032.         : compare1 (target, op1, LE, GE, 0, mode));
  3033.       if (temp == const0_rtx)
  3034.     emit_move_insn (target, op1);
  3035.       else if (temp != const1_rtx)
  3036.     {
  3037.       if (bcc_gen_fctn[(int) GET_CODE (temp)] != 0)
  3038.         emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (temp)]) (op0));
  3039.       else
  3040.         abort ();
  3041.       emit_move_insn (target, op1);
  3042.     }
  3043.       emit_label (op0);
  3044.       return target;
  3045.  
  3046. /* ??? Can optimize when the operand of this is a bitwise operation,
  3047.    by using a different bitwise operation.  */
  3048.     case BIT_NOT_EXPR:
  3049.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3050.       temp = expand_unop (mode, one_cmpl_optab, op0, target, 1);
  3051.       if (temp == 0)
  3052.     abort ();
  3053.       return temp;
  3054.  
  3055.     case FFS_EXPR:
  3056.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3057.       temp = expand_unop (mode, ffs_optab, op0, target, 1);
  3058.       if (temp == 0)
  3059.     abort ();
  3060.       return temp;
  3061.  
  3062. /* ??? Can optimize bitwise operations with one arg constant.
  3063.    Pastel optimizes (a bitwise1 n) bitwise2 (a bitwise3 b)
  3064.    and (a bitwise1 b) bitwise2 b (etc)
  3065.    but that is probably not worth while.  */
  3066.  
  3067. /* BIT_AND_EXPR is for bitwise anding.
  3068.    TRUTH_AND_EXPR is for anding two boolean values
  3069.    when we want in all cases to compute both of them.
  3070.    In general it is fastest to do TRUTH_AND_EXPR by
  3071.    computing both operands as actual zero-or-1 values
  3072.    and then bitwise anding.  In cases where there cannot
  3073.    be any side effects, better code would be made by
  3074.    treating TRUTH_AND_EXPR like TRUTH_ANDIF_EXPR;
  3075.    but the question is how to recognize those cases.  */
  3076.  
  3077.     case TRUTH_AND_EXPR:
  3078.     case BIT_AND_EXPR:
  3079.       preexpand_calls (exp);
  3080.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  3081.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3082.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  3083.       return expand_bit_and (mode, op0, op1, target);
  3084.  
  3085. /* See comment above about TRUTH_AND_EXPR; it applies here too.  */
  3086.     case TRUTH_OR_EXPR:
  3087.     case BIT_IOR_EXPR:
  3088.       preexpand_calls (exp);
  3089.       this_optab = ior_optab;
  3090.       goto binop;
  3091.  
  3092.     case BIT_XOR_EXPR:
  3093.       preexpand_calls (exp);
  3094.       this_optab = xor_optab;
  3095.       goto binop;
  3096.  
  3097.     case LSHIFT_EXPR:
  3098.     case RSHIFT_EXPR:
  3099.     case LROTATE_EXPR:
  3100.     case RROTATE_EXPR:
  3101.       preexpand_calls (exp);
  3102.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  3103.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3104.       return expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target,
  3105.                TREE_UNSIGNED (type));
  3106.  
  3107. /* ??? cv's were used to effect here to combine additive constants
  3108.    and to determine the answer when only additive constants differ.
  3109.    Also, the addition of one can be handled by changing the condition.  */
  3110.     case LT_EXPR:
  3111.     case LE_EXPR:
  3112.     case GT_EXPR:
  3113.     case GE_EXPR:
  3114.     case EQ_EXPR:
  3115.     case NE_EXPR:
  3116.       preexpand_calls (exp);
  3117.       temp = do_store_flag (exp, target, mode);
  3118.       if (temp != 0)
  3119.     return temp;
  3120.       /* For foo != 0, load foo, and if it is nonzero load 1 instead. */
  3121.       if (code == NE_EXPR && integer_zerop (TREE_OPERAND (exp, 1))
  3122.       && subtarget
  3123.       && (GET_MODE (subtarget)
  3124.           == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  3125.     {
  3126.       temp = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3127.       if (temp != subtarget)
  3128.         temp = copy_to_reg (temp);
  3129.       op1 = gen_label_rtx ();
  3130.       emit_cmp_insn (temp, const0_rtx, 0, TREE_UNSIGNED (type), 0);
  3131.       emit_jump_insn (gen_beq (op1));
  3132.       emit_move_insn (temp, const1_rtx);
  3133.       emit_label (op1);
  3134.       return temp;
  3135.     }
  3136.       /* If no set-flag instruction, must generate a conditional
  3137.      store into a temporary variable.  Drop through
  3138.      and handle this like && and ||.  */
  3139.  
  3140.     case TRUTH_ANDIF_EXPR:
  3141.     case TRUTH_ORIF_EXPR:
  3142.       temp = gen_reg_rtx (mode);
  3143.       emit_clr_insn (temp);
  3144.       op1 = gen_label_rtx ();
  3145.       jumpifnot (exp, op1);
  3146.       emit_0_to_1_insn (temp);
  3147.       emit_label (op1);
  3148.       return temp;
  3149.  
  3150.     case TRUTH_NOT_EXPR:
  3151.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  3152.       /* The parser is careful to generate TRUTH_NOT_EXPR
  3153.      only with operands that are always zero or one.  */
  3154.       temp = expand_binop (mode, xor_optab, op0,
  3155.                gen_rtx (CONST_INT, mode, 1),
  3156.                target, 1, OPTAB_LIB_WIDEN);
  3157.       if (temp == 0)
  3158.     abort ();
  3159.       return temp;
  3160.  
  3161.     case COMPOUND_EXPR:
  3162.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  3163.       emit_queue ();
  3164.       return expand_expr (TREE_OPERAND (exp, 1), target, VOIDmode, 0);
  3165.  
  3166.     case COND_EXPR:
  3167.       /* Note that COND_EXPRs whose type is a structure or union
  3168.      are required to be constructed to contain assignments of
  3169.      a temporary variable, so that we can evaluate them here
  3170.      for side effect only.  If type is void, we must do likewise.  */
  3171.       op0 = gen_label_rtx ();
  3172.       op1 = gen_label_rtx ();
  3173.  
  3174.       if (mode == VOIDmode || ignore)
  3175.     temp = 0;
  3176.       else if (target)
  3177.     temp = target;
  3178.       else if (mode == BLKmode)
  3179.     {
  3180.       if (TYPE_SIZE (type) == 0 || ! TREE_LITERAL (TYPE_SIZE (type)))
  3181.         abort ();
  3182.       temp = assign_stack_local (BLKmode,
  3183.                      (TREE_INT_CST_LOW (TYPE_SIZE (type))
  3184.                       * TYPE_SIZE_UNIT (type)
  3185.                       + BITS_PER_UNIT - 1)
  3186.                      / BITS_PER_UNIT);
  3187.     }
  3188.       else
  3189.     temp = gen_reg_rtx (mode);
  3190.  
  3191.       jumpifnot (TREE_OPERAND (exp, 0), op0);
  3192.       NO_DEFER_POP;
  3193.       if (temp != 0)
  3194.     store_expr (TREE_OPERAND (exp, 1), temp, 0);
  3195.       else
  3196.     expand_expr (TREE_OPERAND (exp, 1), ignore ? const0_rtx : 0,
  3197.              VOIDmode, 0);
  3198.       emit_queue ();
  3199.       emit_jump_insn (gen_jump (op1));
  3200.       emit_barrier ();
  3201.       emit_label (op0);
  3202.       if (temp != 0)
  3203.     store_expr (TREE_OPERAND (exp, 2), temp, 0);
  3204.       else
  3205.     expand_expr (TREE_OPERAND (exp, 2), ignore ? const0_rtx : 0,
  3206.              VOIDmode, 0);
  3207.       emit_queue ();
  3208.       emit_label (op1);
  3209.       OK_DEFER_POP;
  3210.       return temp;
  3211.  
  3212.     case MODIFY_EXPR:
  3213.       {
  3214.     /* If lhs is complex, expand calls in rhs before computing it.
  3215.        That's so we don't compute a pointer and save it over a call.
  3216.        If lhs is simple, compute it first so we can give it as a
  3217.        target if the rhs is just a call.  This avoids an extra temp and copy
  3218.        and that prevents a partial-subsumption which makes bad code.
  3219.        Actually we could treat component_ref's of vars like vars.  */
  3220.  
  3221.     tree lhs = TREE_OPERAND (exp, 0);
  3222.     tree rhs = TREE_OPERAND (exp, 1);
  3223.     tree noncopied_parts;
  3224.  
  3225.     if (TREE_CODE (lhs) != VAR_DECL
  3226.         && TREE_CODE (lhs) != RESULT_DECL
  3227.         && TREE_CODE (lhs) != PARM_DECL)
  3228.       preexpand_calls (exp);
  3229.  
  3230.     noncopied_parts = save_noncopied_parts (lhs, TYPE_NONCOPIED_PARTS (TREE_TYPE (lhs)));
  3231.     temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
  3232.     while (noncopied_parts != 0)
  3233.       {
  3234.         store_expr (TREE_VALUE (noncopied_parts),
  3235.             SAVE_EXPR_RTL (TREE_PURPOSE (noncopied_parts)), 0);
  3236.         noncopied_parts = TREE_CHAIN (noncopied_parts);
  3237.       }
  3238.     return temp;
  3239.       }
  3240.  
  3241.     case PREINCREMENT_EXPR:
  3242.     case PREDECREMENT_EXPR:
  3243.       return expand_increment (exp, 0);
  3244.  
  3245.     case POSTINCREMENT_EXPR:
  3246.     case POSTDECREMENT_EXPR:
  3247.       return expand_increment (exp, 1);
  3248.  
  3249.     case ADDR_EXPR:
  3250.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode,
  3251.              EXPAND_CONST_ADDRESS);
  3252.       if (GET_CODE (op0) != MEM)
  3253.     abort ();
  3254.       if (modifier == EXPAND_SUM)
  3255.     return XEXP (op0, 0);
  3256.       op0 = force_operand (XEXP (op0, 0), target);
  3257.       if (flag_force_addr && GET_CODE (op0) != REG)
  3258.     return force_reg (Pmode, op0);
  3259.       return op0;
  3260.  
  3261.     case ENTRY_VALUE_EXPR:
  3262.       abort ();
  3263.  
  3264.     case ERROR_MARK:
  3265.       return const0_rtx;
  3266.  
  3267.     default:
  3268.       abort ();
  3269.     }
  3270.  
  3271.   /* Here to do an ordinary binary operator, generating an instruction
  3272.      from the optab already placed in `this_optab'.  */
  3273.  binop:
  3274.   /* Detect things like x = y | (a == b)
  3275.      and do them as (x = y), (a == b ? x |= 1 : 0), x.  */
  3276.   /* First, get the comparison or conditional into the second arg.  */
  3277.   if (comparison_code[(int) TREE_CODE (TREE_OPERAND (exp, 0))]
  3278.       || (TREE_CODE (TREE_OPERAND (exp, 0)) == COND_EXPR
  3279.       && (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1))
  3280.           || integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 2)))))
  3281.     {
  3282.       if (this_optab == ior_optab || this_optab == add_optab
  3283.       || this_optab == xor_optab)
  3284.     {
  3285.       tree exch = TREE_OPERAND (exp, 1);
  3286.       TREE_OPERAND (exp, 1) = TREE_OPERAND (exp, 0);
  3287.       TREE_OPERAND (exp, 0) = exch;
  3288.     }
  3289.     }
  3290.   /* Optimize X + (Y ? Z : 0) by computing X and maybe adding Z.  */
  3291.   if (comparison_code[(int) TREE_CODE (TREE_OPERAND (exp, 1))]
  3292.       || (TREE_CODE (TREE_OPERAND (exp, 1)) == COND_EXPR
  3293.       && (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 1))
  3294.           || integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 2)))))
  3295.     {
  3296.       if (this_optab == ior_optab || this_optab == add_optab
  3297.       || this_optab == xor_optab || this_optab == sub_optab
  3298.       || this_optab == lshl_optab || this_optab == ashl_optab
  3299.       || this_optab == lshr_optab || this_optab == ashr_optab
  3300.       || this_optab == rotl_optab || this_optab == rotr_optab)
  3301.     {
  3302.       tree thenexp;
  3303.       rtx thenv = 0;
  3304.  
  3305.       /* TARGET gets a reg in which we can perform the computation.
  3306.          Use the specified target if it's a pseudo reg and safe.  */
  3307.       target = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  3308.       if (target == 0) target = gen_reg_rtx (mode);
  3309.  
  3310.       /* Compute X into the target.  */
  3311.       store_expr (TREE_OPERAND (exp, 0), target, 0);
  3312.       op0 = gen_label_rtx ();
  3313.  
  3314.       /* If other operand is a comparison COMP, treat it as COMP ? 1 : 0 */
  3315.       if (TREE_CODE (TREE_OPERAND (exp, 1)) != COND_EXPR)
  3316.         {
  3317.           do_jump (TREE_OPERAND (exp, 1), op0, 0);
  3318.           thenv = const1_rtx;
  3319.         }
  3320.       else if (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 2)))
  3321.         {
  3322.           do_jump (TREE_OPERAND (TREE_OPERAND (exp, 1), 0), op0, 0);
  3323.           thenexp = TREE_OPERAND (TREE_OPERAND (exp, 1), 1);
  3324.         }
  3325.       else
  3326.         {
  3327.           do_jump (TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0, op0);
  3328.           thenexp = TREE_OPERAND (TREE_OPERAND (exp, 1), 2);
  3329.         }
  3330.  
  3331.       if (thenv == 0)
  3332.         thenv = expand_expr (thenexp, 0, VOIDmode, 0);
  3333.  
  3334.       /* THENV is now Z, the value to operate on, as an rtx.
  3335.          We have already tested that Y isn't zero, so do the operation.  */
  3336.  
  3337.       if (this_optab == rotl_optab || this_optab == rotr_optab)
  3338.         temp = expand_binop (mode, this_optab, target, thenv, target,
  3339.                  -1, OPTAB_LIB);
  3340.       else if (this_optab == lshl_optab || this_optab == lshr_optab)
  3341.         temp = expand_binop (mode, this_optab, target, thenv, target,
  3342.                  1, OPTAB_LIB_WIDEN);
  3343.       else
  3344.         temp = expand_binop (mode, this_optab, target, thenv, target,
  3345.                  0, OPTAB_LIB_WIDEN);
  3346.       if (target != temp)
  3347.         emit_move_insn (target, temp);
  3348.  
  3349.       emit_queue ();
  3350.       do_pending_stack_adjust ();
  3351.       emit_label (op0);
  3352.       return target;
  3353.     }
  3354.     }
  3355.   subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  3356.   op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  3357.   op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  3358.  binop2:
  3359.   temp = expand_binop (mode, this_optab, op0, op1, target,
  3360.                TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN);
  3361.   if (temp == 0)
  3362.     abort ();
  3363.   return temp;
  3364. }
  3365. #ifdef MPW
  3366. /* Ugliness to compensate for Mac ugliness.  The segment pragma has to be
  3367.    in an include file so non-ANSI compilers don't get perturbed. */
  3368. #include "seghack.h"
  3369. #endif /* MPW */
  3370.  
  3371. /* Expand an expression EXP that calls a built-in function,
  3372.    with result going to TARGET if that's convenient
  3373.    (and in mode MODE if that's convenient).
  3374.    SUBTARGET may be used as the target for computing one of EXP's operands.
  3375.    IGNORE is nonzero if the value is to be ignored.  */
  3376.  
  3377. static rtx
  3378. expand_builtin (exp, target, subtarget, mode, ignore)
  3379.      tree exp;
  3380.      rtx target;
  3381.      rtx subtarget;
  3382.      enum machine_mode mode;
  3383.      int ignore;
  3384. {
  3385.   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  3386.   tree arglist = TREE_OPERAND (exp, 1);
  3387.   rtx op0;
  3388.  
  3389.   switch (DECL_FUNCTION_CODE (fndecl))
  3390.     {
  3391.     case BUILT_IN_ABS:
  3392.     case BUILT_IN_LABS:
  3393.     case BUILT_IN_FABS:
  3394.       /* build_function_call changes these into ABS_EXPR.  */
  3395.       abort ();
  3396.  
  3397.     case BUILT_IN_SAVEREGS:
  3398.       {
  3399.     /* When this function is called, it means that registers must be
  3400.        saved on entry to this function.  So we migrate the
  3401.        call to the first insn of this function.  */
  3402.     rtx last = get_last_insn ();
  3403.     /* Now really call the function.  `expand_call' does not call
  3404.        expand_builtin, so there is no danger of infinite recursion here.  */
  3405.     rtx temp = expand_call (exp, target, ignore);
  3406.     reorder_insns (NEXT_INSN (last), get_last_insn (), get_insns ());
  3407.     return temp;
  3408.       }
  3409.  
  3410.     case BUILT_IN_CLASSIFY_TYPE:
  3411.       if (arglist != 0)
  3412.     {
  3413.       tree type = TREE_TYPE (TREE_VALUE (arglist));
  3414.       enum tree_code code = TREE_CODE (type);
  3415.       if (code == VOID_TYPE)
  3416.         return gen_rtx (CONST_INT, VOIDmode, void_type_class);
  3417.       if (code == INTEGER_TYPE)
  3418.         return gen_rtx (CONST_INT, VOIDmode, integer_type_class);
  3419.       if (code == CHAR_TYPE)
  3420.         return gen_rtx (CONST_INT, VOIDmode, char_type_class);
  3421.       if (code == ENUMERAL_TYPE)
  3422.         return gen_rtx (CONST_INT, VOIDmode, enumeral_type_class);
  3423.       if (code == BOOLEAN_TYPE)
  3424.         return gen_rtx (CONST_INT, VOIDmode, boolean_type_class);
  3425.       if (code == POINTER_TYPE)
  3426.         return gen_rtx (CONST_INT, VOIDmode, pointer_type_class);
  3427.       if (code == REFERENCE_TYPE)
  3428.         return gen_rtx (CONST_INT, VOIDmode, reference_type_class);
  3429.       if (code == OFFSET_TYPE)
  3430.         return gen_rtx (CONST_INT, VOIDmode, offset_type_class);
  3431.       if (code == REAL_TYPE)
  3432.         return gen_rtx (CONST_INT, VOIDmode, real_type_class);
  3433.       if (code == COMPLEX_TYPE)
  3434.         return gen_rtx (CONST_INT, VOIDmode, complex_type_class);
  3435.       if (code == FUNCTION_TYPE)
  3436.         return gen_rtx (CONST_INT, VOIDmode, function_type_class);
  3437.       if (code == METHOD_TYPE)
  3438.         return gen_rtx (CONST_INT, VOIDmode, method_type_class);
  3439.       if (code == RECORD_TYPE)
  3440.         return gen_rtx (CONST_INT, VOIDmode, record_type_class);
  3441.       if (code == UNION_TYPE)
  3442.         return gen_rtx (CONST_INT, VOIDmode, union_type_class);
  3443.       if (code == ARRAY_TYPE)
  3444.         return gen_rtx (CONST_INT, VOIDmode, array_type_class);
  3445.       if (code == STRING_TYPE)
  3446.         return gen_rtx (CONST_INT, VOIDmode, string_type_class);
  3447.       if (code == SET_TYPE)
  3448.         return gen_rtx (CONST_INT, VOIDmode, set_type_class);
  3449.       if (code == FILE_TYPE)
  3450.         return gen_rtx (CONST_INT, VOIDmode, file_type_class);
  3451.       if (code == LANG_TYPE)
  3452.         return gen_rtx (CONST_INT, VOIDmode, lang_type_class);
  3453.     }
  3454.       return gen_rtx (CONST_INT, VOIDmode, no_type_class);
  3455.  
  3456.     case BUILT_IN_ALLOCA:
  3457.       if (arglist == 0
  3458.       /* Arg could be non-integer if user redeclared this fcn wrong.  */
  3459.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
  3460.     return const0_rtx;
  3461.       frame_pointer_needed = 1;
  3462.       current_function_calls_alloca = 1;
  3463.       /* Compute the argument.  */
  3464.       op0 = expand_expr (TREE_VALUE (arglist), 0, VOIDmode, 0);
  3465.       if (! CONSTANT_P (op0))
  3466.     {
  3467.       op0 = force_reg (GET_MODE (op0), op0);
  3468.       if (GET_MODE (op0) != Pmode)
  3469.         op0 = convert_to_mode (Pmode, op0, 1);
  3470.     }
  3471.       /* Push that much space (rounding it up).  */
  3472.       do_pending_stack_adjust ();
  3473.  
  3474. #ifdef STACK_POINTER_OFFSET
  3475.       /* If we will have to round the result down (which is up
  3476.      if stack grows down), make sure we have extra space so the
  3477.      user still gets at least as much space as he asked for.  */
  3478.       if ((STACK_POINTER_OFFSET + STACK_BYTES - 1) / STACK_BYTES
  3479.       != STACK_POINTER_OFFSET / STACK_BYTES)
  3480.     op0 = plus_constant (op0, STACK_BYTES);
  3481. #endif
  3482.  
  3483. #ifdef STACK_GROWS_DOWNWARD
  3484.       anti_adjust_stack (round_push (op0));
  3485. #endif
  3486.       /* Return a copy of current stack ptr, in TARGET if possible.  */
  3487.       if (target)
  3488.     emit_move_insn (target, stack_pointer_rtx);
  3489.       else
  3490.     target = copy_to_reg (stack_pointer_rtx);
  3491. #ifdef STACK_POINTER_OFFSET
  3492.       /* If the contents of the stack pointer reg are offset from the
  3493.      actual top-of-stack address, add the offset here.  */
  3494.       if (GET_CODE (target) == REG)
  3495.     emit_insn (gen_add2_insn (target,
  3496.                   gen_rtx (CONST_INT, VOIDmode,
  3497.                        (STACK_POINTER_OFFSET + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES)));
  3498.       else
  3499.     {
  3500.       rtx temp =
  3501.         expand_binop (GET_MODE (target), add_optab, target,
  3502.               gen_rtx (CONST_INT, VOIDmode,
  3503.                    (STACK_POINTER_OFFSET + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES),
  3504.               target,
  3505.               1, OPTAB_DIRECT);
  3506.       if (temp == 0) abort ();
  3507.       if (temp != target)
  3508.         emit_move_insn (target, temp);
  3509.     }
  3510. #endif
  3511. #ifndef STACK_GROWS_DOWNWARD
  3512.       anti_adjust_stack (round_push (op0));
  3513. #endif
  3514.       /* Some systems require a particular insn to refer to the stack
  3515.      to make the pages exist.  */
  3516. #ifdef HAVE_probe
  3517.       if (HAVE_probe)
  3518.     emit_insn (gen_probe ());
  3519. #endif
  3520.       return target;
  3521.  
  3522.     case BUILT_IN_FFS:
  3523.       if (arglist == 0
  3524.       /* Arg could be non-integer if user redeclared this fcn wrong.  */
  3525.       || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
  3526.     return const0_rtx;
  3527.  
  3528.       /* Compute the argument.  */
  3529.       op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);
  3530.       /* Compute ffs, into TARGET if possible.
  3531.      Set TARGET to wherever the result comes back.  */
  3532.       target = expand_unop (mode, ffs_optab, op0, target, 1);
  3533.       if (target == 0)
  3534.     abort ();
  3535.       return target;
  3536.  
  3537. #ifdef APPLE_HAX
  3538. #ifdef ADDITIONAL_EXPAND_BUILTIN
  3539.       ADDITIONAL_EXPAND_BUILTIN
  3540. #endif
  3541. #endif /* APPLE_HAX */
  3542.  
  3543.     default:
  3544.       abort ();
  3545.     }
  3546. }
  3547.  
  3548. /* Expand code for a post- or pre- increment or decrement
  3549.    and return the RTX for the result.
  3550.    POST is 1 for postinc/decrements and 0 for preinc/decrements.  */
  3551.  
  3552. static rtx
  3553. expand_increment (exp, post)
  3554.      register tree exp;
  3555.      int post;
  3556. {
  3557.   register rtx op0, op1;
  3558.   register rtx temp;
  3559.   register tree incremented = TREE_OPERAND (exp, 0);
  3560.   optab this_optab = add_optab;
  3561.   int icode;
  3562.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
  3563.   int op0_is_copy = 0;
  3564.  
  3565.   /* Stabilize any component ref that might need to be
  3566.      evaluated more than once below.  */
  3567.   if (TREE_CODE (incremented) == COMPONENT_REF
  3568.       && (TREE_CODE (TREE_OPERAND (incremented, 0)) != INDIRECT_REF
  3569.       || DECL_MODE (TREE_OPERAND (incremented, 1)) == BImode))
  3570.     incremented = stabilize_reference (incremented);
  3571.  
  3572.   /* Compute the operands as RTX.
  3573.      Note whether OP0 is the actual lvalue or a copy of it:
  3574.      I believe it is a copy iff it is a register and insns were
  3575.      generated in computing it.  */
  3576.   temp = get_last_insn ();
  3577.   op0 = expand_expr (incremented, 0, VOIDmode, 0);
  3578.   if (temp != get_last_insn ())
  3579.     op0_is_copy = (GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG);
  3580.   op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  3581.  
  3582.   /* Decide whether incrementing or decrementing.  */
  3583.   if (TREE_CODE (exp) == POSTDECREMENT_EXPR
  3584.       || TREE_CODE (exp) == PREDECREMENT_EXPR)
  3585.     this_optab = sub_optab;
  3586.  
  3587.   /* If OP0 is not the actual lvalue, but rather a copy in a register,
  3588.      then we cannot just increment OP0.  We must
  3589.      therefore contrive to increment the original value.
  3590.      Then we can return OP0 since it is a copy of the old value.  */
  3591.   if (op0_is_copy)
  3592.     {
  3593.       /* This is the easiest way to increment the value wherever it is.
  3594.      Problems with multiple evaluation of INCREMENTED
  3595.      are prevented because either (1) it is a component_ref,
  3596.      in which case it was stabilized above, or (2) it is an array_ref
  3597.      with constant index in an array in a register, which is
  3598.      safe to reevaluate.  */
  3599.       tree newexp = build ((this_optab == add_optab
  3600.                 ? PLUS_EXPR : MINUS_EXPR),
  3601.                TREE_TYPE (exp),
  3602.                incremented,
  3603.                TREE_OPERAND (exp, 1));
  3604.       temp = expand_assignment (incremented, newexp, ! post, 0);
  3605.       return post ? op0 : temp;
  3606.     }
  3607.  
  3608.   /* Convert decrement by a constant into a negative increment.  */
  3609.   if (this_optab == sub_optab
  3610.       && GET_CODE (op1) == CONST_INT)
  3611.     {
  3612.       op1 = gen_rtx (CONST_INT, VOIDmode, - INTVAL (op1));
  3613.       this_optab = add_optab;
  3614.     }
  3615.  
  3616.   if (post)
  3617.     {
  3618.       /* We have a true reference to the value in OP0.
  3619.      If there is an insn to add or subtract in this mode, queue it.  */
  3620.  
  3621.       /* I'm not sure this is still necessary.  */
  3622.       op0 = stabilize (op0);
  3623.  
  3624.       icode = (int) this_optab->handlers[(int) mode].insn_code;
  3625.       if (icode != (int) CODE_FOR_nothing
  3626.       /* Make sure that OP0 is valid for operands 0 and 1
  3627.          of the insn we want to queue.  */
  3628.       && (*insn_operand_predicate[icode][0]) (op0, mode)
  3629.       && (*insn_operand_predicate[icode][1]) (op0, mode))
  3630.     {
  3631.       if (! (*insn_operand_predicate[icode][2]) (op1, mode))
  3632.         op1 = force_reg (mode, op1);
  3633.  
  3634.       return enqueue_insn (op0, GEN_FCN (icode) (op0, op0, op1));
  3635.     }
  3636.     }
  3637.  
  3638.   /* Preincrement, or we can't increment with one simple insn.  */
  3639.   if (post)
  3640.     /* Save a copy of the value before inc or dec, to return it later.  */
  3641.     temp = copy_to_reg (op0);
  3642.   else
  3643.     /* Arrange to return the incremented value.  */
  3644.     /* Copy the rtx because expand_binop will protect from the queue,
  3645.        and the results of that would be invalid for us to return
  3646.        if our caller does emit_queue before using our result.  */
  3647.     temp = copy_rtx (op0);
  3648.  
  3649.   /* Increment however we can.  */
  3650.   op1 = expand_binop (mode, this_optab, op0, op1, op0,
  3651.               TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN);
  3652.   /* Make sure the value is stored into OP0.  */
  3653.   if (op1 != op0)
  3654.     emit_move_insn (op0, op1);
  3655.  
  3656.   return temp;
  3657. }
  3658.  
  3659. /* Expand all function calls contained within EXP, innermost ones first.
  3660.    But don't look within expressions that have sequence points.
  3661.    For each CALL_EXPR, record the rtx for its value
  3662.    in the CALL_EXPR_RTL field.
  3663.  
  3664.    Calls that return large structures for which a structure return
  3665.    stack slot is needed are not preexpanded.  Preexpanding them loses
  3666.    because if more than one were preexpanded they would try to use the
  3667.    same stack slot.  */
  3668.  
  3669. static void
  3670. preexpand_calls (exp)
  3671.      tree exp;
  3672. {
  3673.   register int nops, i;
  3674.  
  3675.   if (! do_preexpand_calls)
  3676.     return;
  3677.  
  3678.   /* Only expressions and references can contain calls.  */
  3679.  
  3680.   if (tree_code_type[(int) TREE_CODE (exp)][0] != 'e'
  3681.       && tree_code_type[(int) TREE_CODE (exp)][0] != 'r')
  3682.     return;
  3683.  
  3684.   switch (TREE_CODE (exp))
  3685.     {
  3686.     case CALL_EXPR:
  3687.       /* Do nothing to built-in functions.  */
  3688.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
  3689.       && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == FUNCTION_DECL
  3690.       && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
  3691.           != NOT_BUILT_IN))
  3692.     return;
  3693.       /* Precompute calls that don't return values in memory.  */
  3694.       if (CALL_EXPR_RTL (exp) == 0
  3695.       && TYPE_MODE (TREE_TYPE (exp)) != BLKmode
  3696.       && ! RETURN_IN_MEMORY (TREE_TYPE (exp)))
  3697.     CALL_EXPR_RTL (exp) = expand_call (exp, 0, 0);
  3698.       return;
  3699.  
  3700.     case COMPOUND_EXPR:
  3701.     case COND_EXPR:
  3702.     case TRUTH_ANDIF_EXPR:
  3703.     case TRUTH_ORIF_EXPR:
  3704.       /* If we find one of these, then we can be sure
  3705.      the adjust will be done for it (since it makes jumps).
  3706.      Do it now, so that if this is inside an argument
  3707.      of a function, we don't get the stack adjustment
  3708.      after some other args have already been pushed.  */
  3709.       do_pending_stack_adjust ();
  3710.       return;
  3711.  
  3712.     case RTL_EXPR:
  3713.       return;
  3714.  
  3715.     case SAVE_EXPR:
  3716.       if (SAVE_EXPR_RTL (exp) != 0)
  3717.     return;
  3718.     }
  3719.  
  3720.   nops = tree_code_length[(int) TREE_CODE (exp)];
  3721.   for (i = 0; i < nops; i++)
  3722.     if (TREE_OPERAND (exp, i) != 0)
  3723.       {
  3724.     register int type = *tree_code_type[(int) TREE_CODE (TREE_OPERAND (exp, i))];
  3725.     if (type == 'e' || type == 'r')
  3726.       preexpand_calls (TREE_OPERAND (exp, i));
  3727.       }
  3728. }
  3729.  
  3730. /* Force FUNEXP into a form suitable for the address of a CALL,
  3731.    and return that as an rtx.  Also load the static chain register
  3732.    from either FUNEXP or CONTEXT.  */
  3733.  
  3734. static rtx
  3735. prepare_call_address (funexp, context)
  3736.      rtx funexp;
  3737.      rtx context;
  3738. {
  3739.   funexp = protect_from_queue (funexp, 0);
  3740.   if (context != 0)
  3741.     context = protect_from_queue (context, 0);
  3742.  
  3743.   /* Function variable in language with nested functions.  */
  3744.   if (GET_MODE (funexp) == EPmode)
  3745.     {
  3746.       emit_move_insn (static_chain_rtx, gen_highpart (Pmode, funexp));
  3747.       funexp = memory_address (FUNCTION_MODE, gen_lowpart (Pmode, funexp));
  3748.       emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx));
  3749.     }
  3750.   else
  3751.     {
  3752.       if (context != 0)
  3753.     /* Unless function variable in C, or top level function constant */
  3754.     emit_move_insn (static_chain_rtx, lookup_static_chain (context));
  3755.  
  3756.       /* Make a valid memory address and copy constants thru pseudo-regs,
  3757.      but not for a constant address if -fno-function-cse.  */
  3758.       if (GET_CODE (funexp) != SYMBOL_REF)
  3759.     funexp = memory_address (FUNCTION_MODE, funexp);
  3760.       else
  3761.     {
  3762. #ifndef NO_FUNCTION_CSE
  3763.       if (optimize && ! flag_no_function_cse)
  3764.         funexp = force_reg (Pmode, funexp);
  3765. #endif
  3766.     }
  3767.  
  3768.       if (context != 0)
  3769.     emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx));
  3770.     }
  3771.   return funexp;
  3772. }
  3773.  
  3774. /* Generate instructions to call function FUNEXP,
  3775.    and optionally pop the results.
  3776.    The CALL_INSN is the first insn generated.
  3777.  
  3778.    FUNTYPE is the data type of the function, or, for a library call,
  3779.    the identifier for the name of the call.  This is given to the
  3780.    macro RETURN_POPS_ARGS to determine whether this function pops its own args.
  3781.  
  3782.    STACK_SIZE is the number of bytes of arguments on the stack,
  3783.    rounded up to STACK_BOUNDARY; zero if the size is variable.
  3784.    This is both to put into the call insn and
  3785.    to generate explicit popping code if necessary.
  3786.  
  3787.    NEXT_ARG_REG is the rtx that results from executing
  3788.      FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1)
  3789.    just after all the args have had their registers assigned.
  3790.    This could be whatever you like, but normally it is the first
  3791.    arg-register beyond those used for args in this call,
  3792.    or 0 if all the arg-registers are used in this call.
  3793.    It is passed on to `gen_call' so you can put this info in the call insn.
  3794.  
  3795.    VALREG is a hard register in which a value is returned,
  3796.    or 0 if the call does not return a value.
  3797.  
  3798.    OLD_INHIBIT_DEFER_POP is the value that `inhibit_defer_pop' had before
  3799.    the args to this call were processed.
  3800.    We restore `inhibit_defer_pop' to that value.
  3801.  
  3802.    USE_INSNS is a SEQUENCE of USE insns to be emitted immediately before
  3803.    the actual CALL insn.  */
  3804.  
  3805. static void
  3806. #ifdef APPLE_C
  3807. /* We need three extra parameters in order to generate pascal and pragma calls correctly. */
  3808. emit_call_1 (funexp, funtype, stack_size, next_arg_reg, valreg, old_inhibit_defer_pop, use_insns, is_pascal, return_mode, fndecl)
  3809. #else
  3810. emit_call_1 (funexp, funtype, stack_size, next_arg_reg, valreg, old_inhibit_defer_pop, use_insns)
  3811. #endif /* APPLE_C */
  3812.      rtx funexp;
  3813.      tree funtype;
  3814.      int stack_size;
  3815.      rtx next_arg_reg;
  3816.      rtx valreg;
  3817.      int old_inhibit_defer_pop;
  3818.      rtx use_insns;
  3819. #ifdef APPLE_C
  3820.      /* Declarations of the extra parameters. */
  3821.      int is_pascal;
  3822.      enum machine_mode return_mode;
  3823.      tree fndecl;
  3824. #endif /* APPLE_C */
  3825. {
  3826.   rtx stack_size_rtx = gen_rtx (CONST_INT, VOIDmode, stack_size);
  3827.   rtx call_insn;
  3828.  
  3829.   if (valreg)
  3830.     emit_call_insn (gen_call_value (valreg,
  3831.                     gen_rtx (MEM, FUNCTION_MODE, funexp),
  3832.                     stack_size_rtx, next_arg_reg));
  3833.   else
  3834.     emit_call_insn (gen_call (gen_rtx (MEM, FUNCTION_MODE, funexp),
  3835.                   stack_size_rtx, next_arg_reg));
  3836.  
  3837.   /* Find the CALL insn we just emitted and write the USE insns before it.  */
  3838.   for (call_insn = get_last_insn();
  3839.        call_insn && GET_CODE (call_insn) != CALL_INSN;
  3840.        call_insn = PREV_INSN (call_insn))
  3841.     ;
  3842.  
  3843.   if (! call_insn)
  3844.     abort ();
  3845.  
  3846.  
  3847.   /* Put the USE insns before the CALL.  */
  3848.   emit_insn_before (use_insns, call_insn);
  3849.  
  3850.   inhibit_defer_pop = old_inhibit_defer_pop;
  3851.  
  3852. #ifdef APPLE_C
  3853.   call_insn->call = is_pascal;
  3854.  
  3855. /*  debug_rtx(call_insn); */
  3856.  
  3857.   if (fndecl == NULL
  3858.       || DECL_PARAM(fndecl) == NULL
  3859.       || DECL_PARAM(fndecl)->funcreturn == noreg)
  3860.     {
  3861.       if (is_pascal)
  3862.         {
  3863.           int adjsize;
  3864.  
  3865.           if (valreg)
  3866.             /* Get the value at sp and put into the result register. */
  3867.         emit_move_insn(valreg,
  3868.                    gen_rtx(MEM, GET_MODE (valreg), stack_pointer_rtx));
  3869.           /* Whether or not the result was put anywhere, the stack still
  3870.              needs to be adjusted to account for the result space alloc. */
  3871.           adjsize = GET_MODE_SIZE (return_mode);
  3872. #ifdef PUSH_ROUNDING
  3873.           adjsize = PUSH_ROUNDING (adjsize);
  3874. #endif
  3875.           if (flag_defer_pop && inhibit_defer_pop == 0)
  3876.         pending_stack_adjust += adjsize;
  3877.           else
  3878.         adjust_stack (gen_rtx (CONST_INT, VOIDmode, adjsize));
  3879.           /* Pascal routines pop args themselves, and we just popped any
  3880.          return stuff, so nothing is left now */
  3881.           stack_size = 0;
  3882.         }
  3883.       }
  3884. #endif /* APPLE_C */
  3885.  
  3886.   /* If returning from the subroutine does not automatically pop the args,
  3887.      we need an instruction to pop them sooner or later.
  3888.      Perhaps do it now; perhaps just record how much space to pop later.  */
  3889.  
  3890.   if (! RETURN_POPS_ARGS (TREE_TYPE (funtype))
  3891.       && stack_size != 0)
  3892.     {
  3893.       if (flag_defer_pop && inhibit_defer_pop == 0)
  3894.     pending_stack_adjust += stack_size;
  3895.       else
  3896.     adjust_stack (stack_size_rtx);
  3897.     }
  3898. }
  3899.  
  3900. /* At the start of a function, record that we have no previously-pushed
  3901.    arguments waiting to be popped.  */
  3902.  
  3903. void
  3904. init_pending_stack_adjust ()
  3905. {
  3906.   pending_stack_adjust = 0;
  3907. }
  3908.  
  3909. /* When exiting from function, if safe, clear out any pending stack adjust
  3910.    so the adjustment won't get done.  */
  3911.  
  3912. void
  3913. clear_pending_stack_adjust ()
  3914. {
  3915. #ifdef EXIT_IGNORE_STACK
  3916.   if (!flag_omit_frame_pointer && EXIT_IGNORE_STACK
  3917.       && ! TREE_INLINE (current_function_decl)
  3918.       && ! flag_inline_functions)
  3919.     pending_stack_adjust = 0;
  3920. #endif
  3921. }
  3922.  
  3923. /* Pop any previously-pushed arguments that have not been popped yet.  */
  3924.  
  3925. void
  3926. do_pending_stack_adjust ()
  3927. {
  3928.   if (inhibit_defer_pop == 0)
  3929.     {
  3930.       if (pending_stack_adjust != 0)
  3931.     adjust_stack (gen_rtx (CONST_INT, VOIDmode, pending_stack_adjust));
  3932.       pending_stack_adjust = 0;
  3933.     }
  3934. }
  3935.  
  3936. /* Data structure and subroutines used within expand_call.  */
  3937.  
  3938. struct arg_data
  3939. {
  3940.   /* Tree node for this argument.  */
  3941.   tree tree_value;
  3942.   /* Precomputed RTL value, or 0 if it isn't precomputed.  */
  3943.   rtx value;
  3944.   /* Register to pass this argument in, or 0 if passed on stack.  */
  3945.   rtx reg;
  3946.   /* Number of registers to use.  0 means put the whole arg in registers.
  3947.      Also 0 if not passed in registers.  */
  3948.   int partial;
  3949.   /* Offset of this argument from beginning of stack-args.  */
  3950.   struct args_size offset;
  3951.   /* Size of this argument on the stack, rounded up for any padding it gets,
  3952.      parts of the argument passed in registers do not count.
  3953.      If the FIRST_PARM_CALLER_OFFSET is negative, then register parms
  3954.      are counted here as well.  */
  3955.   struct args_size size;
  3956.   /* Nonzero if this arg has already been stored.  */
  3957.   int stored;
  3958.   /* const0_rtx means should preallocate stack space for this arg.
  3959.      Other non0 value is the stack slot, preallocated.
  3960.      Used only for BLKmode.  */
  3961.   rtx stack;
  3962. };
  3963.  
  3964. static void store_one_arg ();
  3965. static rtx target_for_arg ();
  3966.  
  3967. /* Generate all the code for a function call
  3968.    and return an rtx for its value.
  3969.    Store the value in TARGET (specified as an rtx) if convenient.
  3970.    If the value is stored in TARGET then TARGET is returned.
  3971.    If IGNORE is nonzero, then we ignore the value of the function call.  */
  3972.  
  3973. static rtx
  3974. expand_call (exp, target, ignore)
  3975.      tree exp;
  3976.      rtx target;
  3977.      int ignore;
  3978. {
  3979.   /* List of actual parameters.  */
  3980.   tree actparms = TREE_OPERAND (exp, 1);
  3981.   /* RTX for the function to be called.  */
  3982.   rtx funexp;
  3983.   /* Data type of the function.  */
  3984.   tree funtype;
  3985.   /* Declaration of the function being called,
  3986.      or 0 if the function is computed (not known by name).  */
  3987.   tree fndecl = 0;
  3988.  
  3989.   /* Register in which non-BLKmode value will be returned,
  3990.      or 0 if no value or if value is BLKmode.  */
  3991.   rtx valreg;
  3992.   /* Address where we should return a BLKmode value;
  3993.      0 if value not BLKmode.  */
  3994.   rtx structure_value_addr = 0;
  3995.   /* Nonzero if that address is being passed by treating it as
  3996.      an extra, implicit first parameter.  Otherwise,
  3997.      it is passed by being copied directly into struct_value_rtx.  */
  3998.   int structure_value_addr_parm = 0;
  3999.   /* Nonzero if called function returns an aggregate in memory PCC style,
  4000.      by returning the address of where to find it.  */
  4001.   int pcc_struct_value = 0;
  4002.  
  4003.   /* Number of actual parameters in this call, including struct value addr.  */
  4004.   int num_actuals;
  4005.   /* Number of named args.  Args after this are anonymous ones
  4006.      and they must all go on the stack.  */
  4007.   int n_named_args;
  4008.  
  4009.   /* Vector of information about each argument.
  4010.      Arguments are numbered in the order they will be pushed,
  4011.      not the order they are written.  */
  4012.   struct arg_data *args;
  4013.  
  4014.   /* Total size in bytes of all the stack-parms scanned so far.  */
  4015.   struct args_size args_size;
  4016.   /* Remember initial value of args_size.constant.  */
  4017.   int starting_args_size;
  4018.   /* Nonzero means count reg-parms' size in ARGS_SIZE.  */
  4019.   int stack_count_regparms = 0;
  4020.   /* Data on reg parms scanned so far.  */
  4021.   CUMULATIVE_ARGS args_so_far;
  4022.   /* Nonzero if a reg parm has been scanned.  */
  4023.   int reg_parm_seen;
  4024.   /* Nonzero if we must avoid push-insns in the args for this call.  */
  4025.   int must_preallocate;
  4026.   /* 1 if scanning parms front to back, -1 if scanning back to front.  */
  4027.   int inc;
  4028.   /* Address of space preallocated for stack parms
  4029.      (on machines that lack push insns), or 0 if space not preallocated.  */
  4030.   rtx argblock = 0;
  4031.  
  4032.   /* Nonzero if it is plausible that this is a call to alloca.  */
  4033.   int may_be_alloca;
  4034.   /* Nonzero if this is a call to setjmp or a related function.  */
  4035.   int is_setjmp;
  4036.   /* Nonzero if this is a call to an inline function.  */
  4037.   int is_integrable = 0;
  4038. #ifdef APPLE_C
  4039.   /* Nonzero if this is a call to a pascal function. */
  4040.   int is_pascal = 0;
  4041.   enum machine_mode pascal_return_mode = VOIDmode;
  4042. #endif /* APPLE_C */
  4043.   /* Nonzero if this is a call to __builtin_new.  */
  4044.   int is_builtin_new;
  4045.   /* Nonzero if this is a call to a `const' function.  */
  4046.   int is_const = 0;
  4047.  
  4048.   /* Nonzero if there are BLKmode args whose data types require them
  4049.      to be passed in memory, not (even partially) in registers.  */
  4050.   int BLKmode_parms_forced = 0;
  4051.   /* The offset of the first BLKmode parameter which 
  4052.      *must* be passed in memory.  */
  4053.   int BLKmode_parms_first_offset = 0;
  4054.   /* Total size of BLKmode parms which could usefully be preallocated.  */
  4055.   int BLKmode_parms_sizes = 0;
  4056.  
  4057.   /* Amount stack was adjusted to protect BLKmode parameters
  4058.      which are below the nominal "stack address" value.  */
  4059.   rtx protected_stack = 0;
  4060.  
  4061.   /* The last insn before the things that are intrinsically part of the call.
  4062.      The beginning reg-note goes on the insn after this one.  */
  4063.   rtx insn_before;
  4064.  
  4065.   rtx old_stack_level = 0;
  4066.   int old_pending_adj;
  4067.   int old_inhibit_defer_pop = inhibit_defer_pop;
  4068.   tree old_cleanups = cleanups_of_this_call;
  4069.   rtx use_insns;
  4070.  
  4071.   register tree p;
  4072.   register int i;
  4073.  
  4074.   /* See if we can find a DECL-node for the actual function.
  4075.      As a result, decide whether this is a call to an integrable function.  */
  4076.  
  4077.   p = TREE_OPERAND (exp, 0);
  4078.   if (TREE_CODE (p) == ADDR_EXPR)
  4079.     {
  4080.       fndecl = TREE_OPERAND (p, 0);
  4081.       if (TREE_CODE (fndecl) != FUNCTION_DECL)
  4082.     fndecl = 0;
  4083.       else
  4084.     {
  4085.       extern tree current_function_decl;
  4086.  
  4087.       if (fndecl != current_function_decl
  4088.           && DECL_SAVED_INSNS (fndecl))
  4089.         is_integrable = 1;
  4090.       else
  4091.         {
  4092.           /* In case this function later becomes inlineable,
  4093.          record that there was already a non-inline call to it.  */
  4094.           mark_addressable (fndecl);
  4095.         }
  4096.  
  4097.       if (TREE_READONLY (fndecl) && ! TREE_THIS_VOLATILE (fndecl))
  4098.         is_const = 1;
  4099. #ifdef APPLE_C
  4100.       if (TREE_PASCAL (fndecl))
  4101.         is_pascal = 1;
  4102. #endif /* APPLE_C */
  4103.     }
  4104.     }
  4105.  
  4106.   /* When calling a const function, we must pop the stack args right away,
  4107.      so that the pop is deleted or moved with the call.  */
  4108.   if (is_const)
  4109.     NO_DEFER_POP;
  4110.  
  4111.   /* Set up a place to return a structure.  */
  4112.  
  4113.   /* Cater to broken compilers.  */
  4114.   if (aggregate_value_p (exp))
  4115.     {
  4116.       /* This call returns a big structure.  */
  4117. #ifdef PCC_STATIC_STRUCT_RETURN
  4118.       if (flag_pcc_struct_return)
  4119.     {
  4120.       pcc_struct_value = 1;
  4121.       is_integrable = 0;  /* Easier than making that case work right.  */
  4122.     }
  4123.       else
  4124. #endif
  4125.     {
  4126.       if (target && GET_CODE (target) == MEM)
  4127.         {
  4128.           structure_value_addr = XEXP (target, 0);
  4129.           if (reg_mentioned_p (stack_pointer_rtx, structure_value_addr))
  4130.         structure_value_addr = copy_to_reg (structure_value_addr);
  4131.         }
  4132.       else
  4133.         {
  4134.           /* Make room on the stack to hold the value.  */
  4135.           structure_value_addr
  4136.         = get_structure_value_addr (expr_size (exp));
  4137.           target = 0;
  4138.         }
  4139.     }
  4140.     }
  4141.  
  4142.   /* If called function is inline, try to integrate it.  */
  4143.  
  4144.   if (is_integrable)
  4145.     {
  4146.       extern rtx expand_inline_function ();
  4147.       rtx temp;
  4148.  
  4149.       temp = expand_inline_function (fndecl, actparms, target,
  4150.                      ignore, TREE_TYPE (exp),
  4151.                      structure_value_addr);
  4152.  
  4153.       /* If inlining succeeded, return.  */
  4154.       if ((int) temp != -1)
  4155.     return temp;
  4156.  
  4157.       /* If inlining failed, mark FNDECL as needing to be compiled
  4158.      separately after all.  */
  4159.       TREE_ADDRESSABLE (fndecl) = 1;
  4160.       TREE_ADDRESSABLE (DECL_NAME (fndecl)) = 1;
  4161.     }
  4162.  
  4163. #if 0
  4164.   /* Unless it's a call to a specific function that isn't alloca,
  4165.      if it has one argument, we must assume it might be alloca.  */
  4166.  
  4167.   may_be_alloca =
  4168.     (!(fndecl != 0
  4169.        && strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)),
  4170.           "alloca"))
  4171.      && actparms != 0
  4172.      && TREE_CHAIN (actparms) == 0);
  4173. #else
  4174.   /* We assume that alloca will always be called by name.  It
  4175.      makes no sense to pass it as a pointer-to-function to
  4176.      anything that does not understand its behavior.  */
  4177.   may_be_alloca =
  4178.     (fndecl && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "alloca")
  4179.         || ! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)),
  4180.                  "__builtin_alloca")));
  4181. #endif
  4182.  
  4183.   /* See if this is a call to a function that can return more than once.  */
  4184.  
  4185.   is_setjmp
  4186.     = (fndecl != 0
  4187.        && (!strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "setjmp")
  4188.        || !strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "_setjmp")));
  4189.  
  4190.   is_builtin_new
  4191.     = (fndecl != 0
  4192.        && (!strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "__builtin_new")));
  4193.  
  4194.   if (may_be_alloca)
  4195.     {
  4196.       frame_pointer_needed = 1;
  4197.       may_call_alloca = 1;
  4198.       current_function_calls_alloca = 1;
  4199.     }
  4200.  
  4201.   /* Don't let pending stack adjusts add up to too much.
  4202.      Also, do all pending adjustments now
  4203.      if there is any chance this might be a call to alloca.  */
  4204.  
  4205.   if (pending_stack_adjust >= 32
  4206.       || (pending_stack_adjust > 0 && may_be_alloca))
  4207.     do_pending_stack_adjust ();
  4208.  
  4209.   /* Operand 0 is a pointer-to-function; get the type of the function.  */
  4210.   funtype = TREE_TYPE (TREE_OPERAND (exp, 0));
  4211.   if (TREE_CODE (funtype) != POINTER_TYPE)
  4212.     abort ();
  4213.   funtype = TREE_TYPE (funtype);
  4214.  
  4215. #ifdef APPLE_C
  4216.   if (TREE_PASCAL (funtype))
  4217.     is_pascal = 1;
  4218. #endif /* APPLE_C */
  4219.  
  4220.   /* If struct_value_rtx is 0, it means pass the address
  4221.      as if it were an extra parameter.  */
  4222.   if (structure_value_addr && struct_value_rtx == 0)
  4223.     {
  4224.       rtx tem;
  4225.  
  4226.       if( fndecl )
  4227.         INIT_CUMULATIVE_ARGS (args_so_far, funtype, DECL_PARAM(fndecl));
  4228.       else
  4229.     INIT_CUMULATIVE_ARGS (args_so_far, funtype, NULL);
  4230.       tem = FUNCTION_ARG (args_so_far, Pmode,
  4231.               build_pointer_type (TREE_TYPE (funtype)), 1);
  4232.       if (tem == 0)
  4233.     {
  4234.       actparms = tree_cons (error_mark_node,
  4235.                 build (SAVE_EXPR,
  4236.                        type_for_size (GET_MODE_BITSIZE (Pmode), 0),
  4237.                        0,
  4238.                        force_reg (Pmode, structure_value_addr)),
  4239.                 actparms);
  4240.       structure_value_addr_parm = 1;
  4241.     }
  4242.     }
  4243.  
  4244. #ifdef APPLE_C
  4245.   if (fndecl == NULL
  4246.       || DECL_PARAM(fndecl) == NULL
  4247.       || DECL_PARAM(fndecl)->funcreturn == noreg )
  4248.   if (is_pascal && TYPE_MODE (TREE_TYPE (exp)) != VOIDmode)
  4249.     {
  4250.       if (structure_value_addr && ! structure_value_addr_parm)
  4251.     {
  4252.       emit_move_insn (struct_value_rtx,
  4253.               force_reg (Pmode,
  4254.                      force_operand (structure_value_addr, 0)));
  4255.         }
  4256.       else
  4257.     {
  4258.       pascal_return_mode = TYPE_MODE (TREE_TYPE (exp));
  4259. #ifdef PUSH_ROUNDING
  4260.       push_block (gen_rtx (CONST_INT, VOIDmode,
  4261.                    PUSH_ROUNDING (GET_MODE_SIZE (pascal_return_mode))));
  4262. #else
  4263.       push_block (gen_rtx (CONST_INT, VOIDmode,
  4264.                    GET_MODE_SIZE (pascal_return_mode)));
  4265. #endif
  4266.         }
  4267.     }
  4268. #endif /* APPLE_C */
  4269.   /* Count the arguments and set NUM_ACTUALS.  */
  4270.   for (p = actparms, i = 0; p; p = TREE_CHAIN (p)) i++;
  4271.   num_actuals = i;
  4272.  
  4273.   /* Compute number of named args.
  4274.      Don't include the last named arg if anonymous args follow.
  4275.      (If no anonymous args follow, the result of list_length
  4276.      is actually one too large.)  */
  4277.   if (TYPE_ARG_TYPES (funtype) != 0)
  4278.     n_named_args = list_length (TYPE_ARG_TYPES (funtype)) - 1;
  4279.   else
  4280.     /* If we know nothing, treat all args as named.  */
  4281.     n_named_args = num_actuals;
  4282.  
  4283.   /* Make a vector to hold all the information about each arg.  */
  4284.   args = (struct arg_data *) alloca (num_actuals * sizeof (struct arg_data));
  4285.   bzero (args, num_actuals * sizeof (struct arg_data));
  4286.  
  4287.   args_size.constant = 0;
  4288.   args_size.var = 0;
  4289. #ifdef FIRST_PARM_CALLER_OFFSET
  4290.   args_size.constant = FIRST_PARM_CALLER_OFFSET (funtype);
  4291.   stack_count_regparms = 1;
  4292. #endif
  4293.   starting_args_size = args_size.constant;
  4294.  
  4295.   /* In this loop, we consider args in the order they are written.
  4296.      We fill up ARGS from the front of from the back if necessary
  4297.      so that in any case the first arg to be pushed ends up at the front.  */
  4298.  
  4299. #ifdef APPLE_C
  4300.   push_args_reversed = (is_pascal ? 0 : 1);
  4301.  
  4302.   i = (push_args_reversed ? num_actuals - 1 : 0);
  4303.   inc = (push_args_reversed ? -1 : 1);
  4304. #else
  4305. #ifdef PUSH_ARGS_REVERSED
  4306.   i = num_actuals - 1, inc = -1;
  4307.   /* In this case, must reverse order of args
  4308.      so that we compute and push the last arg first.  */
  4309. #else
  4310.   i = 0, inc = 1;
  4311. #endif
  4312. #endif /* APPLE_C */
  4313.  
  4314.   if( fndecl )
  4315.     INIT_CUMULATIVE_ARGS (args_so_far, funtype, DECL_PARAM(fndecl));
  4316.   else
  4317.     INIT_CUMULATIVE_ARGS (args_so_far, funtype, NULL);
  4318.  
  4319.   for (p = actparms; p; p = TREE_CHAIN (p), i += inc)
  4320.     {
  4321.       tree type = TREE_TYPE (TREE_VALUE (p));
  4322.       args[i].tree_value = TREE_VALUE (p);
  4323.       args[i].offset = args_size;
  4324.  
  4325.       if (type == error_mark_node
  4326.       || TYPE_SIZE (type) == 0)
  4327.     continue;
  4328.  
  4329.       /* Decide where to pass this arg.  */
  4330.       /* args[i].reg is nonzero if all or part is passed in registers.
  4331.      args[i].partial is nonzero if part but not all is passed in registers,
  4332.       and the exact value says how many words are passed in registers.  */
  4333.  
  4334.       if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
  4335.       && args_size.var == 0
  4336.       /* error_mark_node here is a flag for the fake argument
  4337.          for a structure value address.  */
  4338.       && TREE_PURPOSE (p) != error_mark_node)
  4339.     {
  4340.       args[i].reg = FUNCTION_ARG (args_so_far, TYPE_MODE (type), type,
  4341.                       i < n_named_args);
  4342.       /* If this argument needs more than the usual parm alignment, do
  4343.          extrinsic padding to reach that alignment.  */
  4344.  
  4345. #ifdef MAX_PARM_BOUNDARY
  4346.       /* If MAX_PARM_BOUNDARY is not defined, it means that the usual
  4347.          alignment requirements are relaxed for parms, and that no parm
  4348.          needs more than PARM_BOUNDARY, regardless of data type.  */
  4349.  
  4350.       if (PARM_BOUNDARY < TYPE_ALIGN (type))
  4351.         {
  4352.           int boundary = PARM_BOUNDARY;
  4353.  
  4354.           /* Determine the boundary to pad up to.  */
  4355.           if (TYPE_ALIGN (type) > boundary)
  4356.         boundary = TYPE_ALIGN (type);
  4357.           if (boundary > MAX_PARM_BOUNDARY)
  4358.         boundary = MAX_PARM_BOUNDARY;
  4359.  
  4360.           /* If the previous args don't reach such a boundary,
  4361.          advance to the next one.  */
  4362.           boundary /= BITS_PER_UNIT;
  4363.           args[i].offset.constant += boundary - 1;
  4364.           args[i].offset.constant &= ~(boundary - 1);
  4365.           args_size.constant += boundary - 1;
  4366.           args_size.constant &= ~(boundary - 1);
  4367.  
  4368.           if (args_size.var != 0)
  4369.         abort ();        /* This case not implemented yet */
  4370.         }
  4371. #endif /* MAX_PARM_BOUNDARY */
  4372.  
  4373. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  4374.       args[i].partial
  4375.         = FUNCTION_ARG_PARTIAL_NREGS (args_so_far,
  4376.                       TYPE_MODE (type), type,
  4377.                       i < n_named_args);
  4378. #endif
  4379.     }
  4380.  
  4381.       /* Compute the stack-size of this argument.  */
  4382.  
  4383.       if (args[i].reg != 0 && args[i].partial == 0
  4384.       && ! stack_count_regparms)
  4385.     /* On most machines, don't count stack space for a register arg.  */
  4386.     ;
  4387.       else if (TYPE_MODE (type) != BLKmode)
  4388.     {
  4389.       register int size;
  4390.  
  4391.       size = GET_MODE_SIZE (TYPE_MODE (type));
  4392.       /* Compute how much space the push instruction will push.
  4393.          On many machines, pushing a byte will advance the stack
  4394.          pointer by a halfword.  */
  4395. #ifdef PUSH_ROUNDING
  4396.       size = PUSH_ROUNDING (size);
  4397. #endif
  4398.       /* Compute how much space the argument should get:
  4399.          maybe pad to a multiple of the alignment for arguments.  */
  4400.       if (none == FUNCTION_ARG_PADDING (TYPE_MODE (type), const0_rtx))
  4401.         args[i].size.constant = size;
  4402.       else
  4403.         args[i].size.constant
  4404.           = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
  4405.           / (PARM_BOUNDARY / BITS_PER_UNIT))
  4406.          * (PARM_BOUNDARY / BITS_PER_UNIT));
  4407.     }
  4408.       else
  4409.     {
  4410.       register tree size = size_in_bytes (type);
  4411.  
  4412.       /* A nonscalar.  Round its size up to a multiple
  4413.          of PARM_BOUNDARY bits, unless it is not supposed to be padded.  */
  4414.       if (none
  4415.           != FUNCTION_ARG_PADDING (TYPE_MODE (type),
  4416.                        expand_expr (size, 0, VOIDmode, 0)))
  4417.         size = convert_units (convert_units (size, BITS_PER_UNIT,
  4418.                          PARM_BOUNDARY),
  4419.                   PARM_BOUNDARY, BITS_PER_UNIT);
  4420.       ADD_PARM_SIZE (args[i].size, size);
  4421.  
  4422.       /* Certain data types may not be passed in registers
  4423.          (eg C++ classes with constructors).
  4424.          Also, BLKmode parameters initialized from CALL_EXPRs
  4425.          are treated specially, if it is a win to do so.  */
  4426.       if (TREE_CODE (TREE_VALUE (p)) == CALL_EXPR
  4427.           || TREE_ADDRESSABLE (type))
  4428.         {
  4429.           if (TREE_ADDRESSABLE (type))
  4430.         BLKmode_parms_forced = 1;
  4431.           /* This is a marker for such a parameter.  */
  4432.           args[i].stack = const0_rtx;
  4433.           BLKmode_parms_sizes += TREE_INT_CST_LOW (size);
  4434.  
  4435.           /* If this parm's location is "below" the nominal stack pointer,
  4436.          note to decrement the stack pointer while it is computed.  */
  4437. #ifdef FIRST_PARM_CALLER_OFFSET
  4438.           if (BLKmode_parms_first_offset == 0)
  4439.         BLKmode_parms_first_offset
  4440.           /* If parameter's offset is variable, assume the worst.  */
  4441.           = (args[i].offset.var
  4442.              ? FIRST_PARM_CALLER_OFFSET (funtype)
  4443.              : args[i].offset.constant);
  4444. #endif
  4445.         }
  4446.     }
  4447.  
  4448.       /* If a part of the arg was put into registers,
  4449.      don't include that part in the amount pushed.  */
  4450.       if (! stack_count_regparms)
  4451.     args[i].size.constant
  4452.       -= ((args[i].partial * UNITS_PER_WORD)
  4453.           / (PARM_BOUNDARY / BITS_PER_UNIT)
  4454.           * (PARM_BOUNDARY / BITS_PER_UNIT));
  4455.  
  4456.       /* Update ARGS_SIZE, the total stack space for args so far.  */
  4457.  
  4458.       args_size.constant += args[i].size.constant;
  4459.       if (args[i].size.var)
  4460.     {
  4461.       ADD_PARM_SIZE (args_size, args[i].size.var);
  4462.     }
  4463.  
  4464.       /* Increment ARGS_SO_FAR, which has info about which arg-registers
  4465.      have been used, etc.  */
  4466.  
  4467.       FUNCTION_ARG_ADVANCE (args_so_far, TYPE_MODE (type), type,
  4468.                 i < n_named_args);
  4469.     }
  4470.  
  4471.   /* If we would have to push a partially-in-regs parm
  4472.      before other stack parms, preallocate stack space instead.  */
  4473.   must_preallocate = 0;
  4474.   {
  4475.     int partial_seen = 0;
  4476.     for (i = 0; i < num_actuals; i++)
  4477.       {
  4478.     if (args[i].partial > 0)
  4479.       partial_seen = 1;
  4480.     else if (partial_seen && args[i].reg == 0)
  4481.       must_preallocate = 1;
  4482.       }
  4483.   }
  4484.  
  4485.   /* Precompute all register parameters.  It isn't safe to compute anything
  4486.      once we have started filling any specific hard regs.
  4487.      If this function call is cse'able, precompute all the parameters.  */
  4488.  
  4489.   reg_parm_seen = 0;
  4490.   for (i = 0; i < num_actuals; i++)
  4491.     if (args[i].reg != 0 || is_const)
  4492.       {
  4493.     int j;
  4494.     int struct_value_lossage = 0;
  4495.  
  4496.     /* First, see if this is a precomputed struct-returning function call
  4497.        and other subsequent parms are also such.  */
  4498.     if ((TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
  4499.          || RETURN_IN_MEMORY (TREE_TYPE (args[i].tree_value)))
  4500.         && TREE_CODE (args[i].tree_value) == CALL_EXPR)
  4501.       for (j = i + 1; j < num_actuals; j++)
  4502.         if ((TYPE_MODE (TREE_TYPE (args[j].tree_value)) == BLKmode
  4503.          || RETURN_IN_MEMORY (TREE_TYPE (args[j].tree_value)))
  4504.         && TREE_CODE (args[j].tree_value) == CALL_EXPR
  4505.         && args[j].reg != 0 || is_const)
  4506.           {
  4507.         /* We have two precomputed structure-values call expressions
  4508.            in our parm list.  Both of them would normally use
  4509.            the structure-value block.  To avoid the conflict,
  4510.            compute this parm with a different temporary block.  */
  4511.         int size = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
  4512.         rtx structval = assign_stack_local (BLKmode, size);
  4513.         args[i].value = expand_expr (args[i].tree_value, structval,
  4514.                          VOIDmode, 0);
  4515.         struct_value_lossage = 1;
  4516.         break;
  4517.           }
  4518.     if (!struct_value_lossage)
  4519.       args[i].value = expand_expr (args[i].tree_value, 0, VOIDmode, 0);
  4520.  
  4521.     if (args[i].reg != 0)
  4522.       reg_parm_seen = 1;
  4523.  
  4524.     if (GET_CODE (args[i].value) != MEM
  4525.         && ! CONSTANT_P (args[i].value)
  4526.         && GET_CODE (args[i].value) != CONST_DOUBLE)
  4527.       args[i].value
  4528.         = force_reg (TYPE_MODE (TREE_TYPE (args[i].tree_value)),
  4529.              args[i].value);
  4530.     /* ANSI doesn't require a sequence point here,
  4531.        but PCC has one, so this will avoid some problems.  */
  4532.     emit_queue ();
  4533.       }
  4534.  
  4535.   /* Get the function to call, in the form of RTL, if it is a constant.  */
  4536.   if (fndecl && is_const)
  4537.     {
  4538.       /* Get a SYMBOL_REF rtx for the function address.  */
  4539.       funexp = XEXP (DECL_RTL (fndecl), 0);
  4540.  
  4541. #ifndef NO_FUNCTION_CSE
  4542.       /* Pass the address through a pseudoreg, if desired,
  4543.      before the "beginning" of the library call.
  4544.      So this insn isn't "part of" the library call, in case that
  4545.      is deleted, or cse'd.  */
  4546.       if (! flag_no_function_cse)
  4547.     funexp = copy_to_mode_reg (Pmode, funexp);
  4548. #endif
  4549.     }
  4550.  
  4551.   /* Now we are about to start emitting insns that can be deleted
  4552.      if the libcall is deleted.  */
  4553.   insn_before = get_last_insn ();
  4554.  
  4555.   /* Maybe do additional rounding on the size of the arguments.  */
  4556. #ifdef STACK_ARGS_ADJUST
  4557.   STACK_ARGS_ADJUST (args_size);
  4558. #endif
  4559.  
  4560.   /* If we have no actual push instructions, or shouldn't use them,
  4561.      or we need a variable amount of space, make space for all args right now.
  4562.      Round the needed size up to multiple of STACK_BOUNDARY.  */
  4563.  
  4564.   if (args_size.var != 0)
  4565.     {
  4566.       old_stack_level = copy_to_mode_reg (Pmode, stack_pointer_rtx);
  4567.       old_pending_adj = pending_stack_adjust;
  4568.       argblock = push_block (round_push (ARGS_SIZE_RTX (args_size)));
  4569.     }
  4570.   else if (args_size.constant > 0)
  4571.     {
  4572.       int needed = args_size.constant;
  4573.  
  4574. #ifdef STACK_BOUNDARY
  4575.       needed = (needed + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES;
  4576. #endif
  4577.       args_size.constant = needed;
  4578.  
  4579.       if (
  4580. #ifndef PUSH_ROUNDING
  4581.       1  /* Always preallocate if no push insns.  */
  4582. #else
  4583.       must_preallocate || BLKmode_parms_forced
  4584.       || BLKmode_parms_sizes > (args_size.constant >> 1)
  4585. #endif
  4586.       )
  4587.     {
  4588.       /* Try to reuse some or all of the pending_stack_adjust
  4589.          to get this space.  Maybe we can avoid any pushing.  */
  4590.       if (needed > pending_stack_adjust)
  4591.         {
  4592.           needed -= pending_stack_adjust;
  4593.           pending_stack_adjust = 0;
  4594.         }
  4595.       else
  4596.         {
  4597.           pending_stack_adjust -= needed;
  4598.           needed = 0;
  4599.         }
  4600.       argblock = push_block (gen_rtx (CONST_INT, VOIDmode, needed));
  4601.     }
  4602.     }
  4603. #ifndef PUSH_ROUNDING
  4604.   else if (BLKmode_parms_forced)
  4605.     {
  4606.       /* If we have reg-parms that need to be temporarily on the stack,
  4607.      set up an arg block address even though there is no space
  4608.      to be allocated for it.  */
  4609.       argblock = push_block (const0_rtx);
  4610.     }
  4611. #endif
  4612.  
  4613. #if 0
  4614.   /* If stack needs padding below the args, increase all arg offsets
  4615.      so the args are stored above the padding.  */
  4616.   if (stack_padding)
  4617.     for (i = 0; i < num_actuals; i++)
  4618.       args[i].offset.constant += stack_padding;
  4619. #endif
  4620.  
  4621.   /* Don't try to defer pops if preallocating, not even from the first arg,
  4622.      since ARGBLOCK probably refers to the SP.  */
  4623.   if (argblock)
  4624.     NO_DEFER_POP;
  4625.  
  4626. #ifdef STACK_GROWS_DOWNWARD
  4627.   /* If any BLKmode parms need to be preallocated in space
  4628.      below the nominal stack-pointer address, we need to adjust the
  4629.      stack pointer so that this location is temporarily above it.
  4630.      This ensures that computation won't clobber that space.  */
  4631.   if (BLKmode_parms_first_offset < 0 && argblock != 0)
  4632.     {
  4633.       int needed = -BLKmode_parms_first_offset;
  4634.       argblock = copy_to_reg (argblock);
  4635.  
  4636. #ifdef STACK_BOUNDARY
  4637.       needed = (needed + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES;
  4638. #endif
  4639.       protected_stack = gen_rtx (CONST_INT, VOIDmode, needed);
  4640.       anti_adjust_stack (protected_stack);
  4641.     }
  4642. #endif /* STACK_GROWS_DOWNWARD */
  4643.  
  4644.   /* Get the function to call, in the form of RTL.  */
  4645.   if (fndecl)
  4646.     /* Get a SYMBOL_REF rtx for the function address.  */
  4647.     funexp = XEXP (DECL_RTL (fndecl), 0);
  4648.   else
  4649.     /* Generate an rtx (probably a pseudo-register) for the address.  */
  4650.     {
  4651.       funexp = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  4652.       emit_queue ();
  4653.     }
  4654.  
  4655.   /* Now compute and store all non-register parms.
  4656.      These come before register parms, since they can require block-moves,
  4657.      which could clobber the registers used for register parms.
  4658.      Parms which have partial registers are not stored here,
  4659.      but we do preallocate space here if they want that.  */
  4660.  
  4661.   for (i = 0; i < num_actuals; i++)
  4662.     {
  4663.       /* Preallocate the stack space for a parm if appropriate
  4664.      so it can be computed directly in the stack space.  */
  4665.       if (args[i].stack != 0 && argblock != 0)
  4666.     args[i].stack = target_for_arg (TREE_TYPE (args[i].tree_value),
  4667.                     ARGS_SIZE_RTX (args[i].size),
  4668.                     argblock, args[i].offset);
  4669.       else
  4670.     args[i].stack = 0;
  4671.  
  4672.       if (args[i].reg == 0
  4673.       && TYPE_SIZE (TREE_TYPE (args[i].tree_value)) != 0)
  4674.     store_one_arg (&args[i], argblock, may_be_alloca);
  4675.     }
  4676.  
  4677.   /* Now store any partially-in-registers parm.
  4678.      This is the last place a block-move can happen.  */
  4679.   if (reg_parm_seen)
  4680.     for (i = 0; i < num_actuals; i++)
  4681.       if (args[i].partial != 0)
  4682.     store_one_arg (&args[i], argblock, may_be_alloca);
  4683.  
  4684.   if (protected_stack != 0)
  4685.     adjust_stack (protected_stack);
  4686.  
  4687.   /* Pass the function the address in which to return a structure value.  */
  4688. #ifdef APPLE_C
  4689.   if (structure_value_addr && ! structure_value_addr_parm && ! is_pascal)
  4690. #else
  4691.   if (structure_value_addr && ! structure_value_addr_parm)
  4692. #endif /* APPLE_C */
  4693.     emit_move_insn (struct_value_rtx,
  4694.             force_reg (Pmode, force_operand (structure_value_addr, 0)));
  4695.  
  4696.   /* Now set up any wholly-register parms.  They were computed already.  */
  4697.   if (reg_parm_seen)
  4698.     for (i = 0; i < num_actuals; i++)
  4699.       if (args[i].reg != 0 && args[i].partial == 0)
  4700.     store_one_arg (&args[i], argblock, may_be_alloca);
  4701.  
  4702.   /* Perform postincrements before actually calling the function.  */
  4703.   emit_queue ();
  4704.  
  4705.   /* All arguments and registers used for the call must be set up by now!  */
  4706.  
  4707.   /* ??? Other languages need a nontrivial second argument (static chain).  */
  4708.   funexp = prepare_call_address (funexp, 0);
  4709.  
  4710.   /* Mark all register-parms as living through the call.  */
  4711.   start_sequence ();
  4712.   for (i = 0; i < num_actuals; i++)
  4713.     if (args[i].reg != 0)
  4714.       {
  4715.     if (args[i].partial > 0)
  4716.       use_regs (REGNO (args[i].reg), args[i].partial);
  4717.     else if (GET_MODE (args[i].reg) == BLKmode)
  4718.       use_regs (REGNO (args[i].reg),
  4719.             ((int_size_in_bytes (TREE_TYPE (args[i].tree_value))
  4720.               + UNITS_PER_WORD - 1)
  4721.              / UNITS_PER_WORD));
  4722.     else
  4723.       emit_insn (gen_rtx (USE, VOIDmode, args[i].reg));
  4724.       }
  4725.  
  4726.   if (structure_value_addr && ! structure_value_addr_parm
  4727.       && GET_CODE (struct_value_rtx) == REG)
  4728.     emit_insn (gen_rtx (USE, VOIDmode, struct_value_rtx));
  4729.  
  4730.   use_insns = gen_sequence ();
  4731.   end_sequence ();
  4732.  
  4733.   /* Figure out the register where the value, if any, will come back.  */
  4734.   valreg = 0;
  4735.   if (TYPE_MODE (TREE_TYPE (exp)) != VOIDmode
  4736.       && ! structure_value_addr)
  4737.     {
  4738.       if (pcc_struct_value)
  4739.     valreg = hard_libcall_value (Pmode);
  4740.       else
  4741.     valreg = hard_function_value (TREE_TYPE (exp), fndecl);
  4742.     }
  4743.  
  4744.   /* Generate the actual call instruction.  */
  4745.   /* This also has the effect of turning off any pop-inhibition
  4746.      done in expand_call.  */
  4747.   if (args_size.constant < 0)
  4748.     args_size.constant = 0;
  4749.   emit_call_1 (funexp, funtype, args_size.constant,
  4750.            FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
  4751. #ifdef APPLE_C
  4752.            valreg, old_inhibit_defer_pop, use_insns, is_pascal, pascal_return_mode, fndecl);
  4753. #else
  4754.            valreg, old_inhibit_defer_pop, use_insns);
  4755. #endif /* APPLE_C */
  4756.  
  4757. /* ???  Nothing has been done here to record control flow
  4758.    when contained functions can do nonlocal gotos.  */
  4759.  
  4760.   /* For calls to `setjmp', etc., inform flow.c it should complain
  4761.      if nonvolatile values are live.  */
  4762.  
  4763.   if (is_setjmp)
  4764.     {
  4765.       emit_note (IDENTIFIER_POINTER (DECL_NAME (fndecl)), NOTE_INSN_SETJMP);
  4766.       current_function_calls_setjmp = 1;
  4767.     }
  4768.  
  4769.   /* Notice functions that cannot return.
  4770.      If optimizing, insns emitted below will be dead.
  4771.      If not optimizing, they will exist, which is useful
  4772.      if the user uses the `return' command in the debugger.  */
  4773.  
  4774.   if (fndecl && TREE_THIS_VOLATILE (fndecl))
  4775.     emit_barrier ();
  4776.  
  4777.   /* For calls to __builtin_new, note that it can never return 0.
  4778.      This is because a new handler will be called, and 0 it not
  4779.      among the numbers it is supposed to return.  */
  4780. #if 0
  4781.   if (is_builtin_new)
  4782.     emit_note (IDENTIFIER_POINTER (DECL_NAME (fndecl)), NOTE_INSN_BUILTIN_NEW);
  4783. #endif
  4784.  
  4785.   /* If value type not void, return an rtx for the value.  */
  4786.  
  4787.   /* If there are cleanups to be called, don't use a hard reg as target.  */
  4788.   if (cleanups_of_this_call != old_cleanups
  4789.       && target && REG_P (target)
  4790.       && REGNO (target) < FIRST_PSEUDO_REGISTER)
  4791.     target = 0;
  4792.  
  4793.   if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode
  4794.       || ignore)
  4795.     {
  4796.       target = const0_rtx;
  4797.     }
  4798.   else if (structure_value_addr)
  4799.     {
  4800.       if (target == 0 || GET_CODE (target) != MEM)
  4801.     target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
  4802.               memory_address (BLKmode, structure_value_addr));
  4803.     }
  4804.   else if (pcc_struct_value)
  4805.     {
  4806.       valreg = hard_function_value (build_pointer_type (TREE_TYPE (exp)),
  4807.                     fndecl);
  4808.       if (target == 0)
  4809.     target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
  4810.               copy_to_reg (valreg));
  4811.       else if (TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
  4812.     emit_move_insn (target, gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
  4813.                      copy_to_reg (valreg)));
  4814.       else
  4815.     emit_block_move (target, gen_rtx (MEM, BLKmode, copy_to_reg (valreg)),
  4816.              expr_size (exp),
  4817.              TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  4818.     }
  4819.   else if (target && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp)))
  4820.     {
  4821.       if (!rtx_equal_p (target, valreg))
  4822.     emit_move_insn (target, valreg);
  4823.       else
  4824.     /* This tells expand_inline_function to copy valreg to its target.  */
  4825.     emit_insn (gen_rtx (USE, VOIDmode, valreg));
  4826.     }
  4827.   else
  4828.     target = copy_to_reg (valreg);
  4829.  
  4830.   /* Perform all cleanups needed for the arguments of this call
  4831.      (i.e. destructors in C++).  */
  4832.   while (cleanups_of_this_call != old_cleanups)
  4833.     {
  4834.       expand_expr (TREE_VALUE (cleanups_of_this_call), 0, VOIDmode, 0);
  4835.       cleanups_of_this_call = TREE_CHAIN (cleanups_of_this_call);
  4836.     }
  4837.  
  4838.   /* If size of args is variable, restore saved stack-pointer value.  */
  4839.  
  4840.   if (old_stack_level)
  4841.     {
  4842.       emit_move_insn (stack_pointer_rtx, old_stack_level);
  4843.       pending_stack_adjust = old_pending_adj;
  4844.     }
  4845.  
  4846.   /* If call is cse'able, make appropriate pair of reg-notes around it.  */
  4847.   if (is_const)
  4848.     {
  4849.       rtx insn_first = NEXT_INSN (insn_before);
  4850.       rtx insn_last = get_last_insn ();
  4851.       rtx note = 0;
  4852.  
  4853.       /* Don't put the notes on if we don't have insns that can hold them.  */
  4854.       if ((GET_CODE (insn_first) == INSN
  4855.        || GET_CODE (insn_first) == CALL_INSN
  4856.        || GET_CODE (insn_first) == JUMP_INSN)
  4857.       && (GET_CODE (insn_last) == INSN
  4858.           || GET_CODE (insn_last) == CALL_INSN
  4859.           || GET_CODE (insn_last) == JUMP_INSN))
  4860.     {
  4861.       /* Construct an "equal form" for the value
  4862.          which mentions all the arguments in order
  4863.          as well as the function name.  */
  4864.       for (i = 0; i < num_actuals; i++)
  4865.         if (args[i].reg != 0 || is_const)
  4866.           note = gen_rtx (EXPR_LIST, VOIDmode, args[i].value, note);
  4867.       note = gen_rtx (EXPR_LIST, VOIDmode,
  4868.               XEXP (DECL_RTL (fndecl), 0), note);
  4869.  
  4870.       REG_NOTES (insn_last)
  4871.         = gen_rtx (EXPR_LIST, REG_EQUAL, note,
  4872.                gen_rtx (INSN_LIST, REG_RETVAL, insn_first,
  4873.                 REG_NOTES (insn_last)));
  4874.       REG_NOTES (insn_first)
  4875.         = gen_rtx (INSN_LIST, REG_LIBCALL, insn_last,
  4876.                REG_NOTES (insn_first));
  4877.     }
  4878.     }
  4879.  
  4880.   return target;
  4881. }
  4882.  
  4883. /* Return an rtx which represents a suitable home on the stack
  4884.    given TYPE, the type of the argument looking for a home.
  4885.    This is called only for BLKmode arguments.
  4886.  
  4887.    SIZE is the size needed for this target.
  4888.    ARGS_ADDR is the address of the bottom of the argument block for this call.
  4889.    OFFSET describes this parameter's offset into ARGS_ADDR.  It is meaningless
  4890.    if this machine uses push insns.  */
  4891.  
  4892. static rtx
  4893. target_for_arg (type, size, args_addr, offset)
  4894.      tree type;
  4895.      rtx size;
  4896.      rtx args_addr;
  4897.      struct args_size offset;
  4898. {
  4899.   rtx target;
  4900.   rtx offset_rtx = ARGS_SIZE_RTX (offset);
  4901.  
  4902.   /* We do not call memory_address if possible,
  4903.      because we want to address as close to the stack
  4904.      as possible.  For non-variable sized arguments,
  4905.      this will be stack-pointer relative addressing.  */
  4906.   if (GET_CODE (offset_rtx) == CONST_INT)
  4907.     target = plus_constant (args_addr, INTVAL (offset_rtx));
  4908.   else
  4909.     {
  4910.       /* I have no idea how to guarantee that this
  4911.      will work in the presence of register parameters.  */
  4912.       target = gen_rtx (PLUS, Pmode, args_addr, offset_rtx);
  4913.       target = memory_address (QImode, target);
  4914.     }
  4915.  
  4916.   return gen_rtx (MEM, BLKmode, target);
  4917. }
  4918.  
  4919. /* Store a single argument for a function call
  4920.    into the register or memory area where it must be passed.
  4921.    *ARG describes the argument value and where to pass it.
  4922.    ARGBLOCK is the address of the stack-block for all the arguments,
  4923.    or 0 on a machine where arguemnts are pushed individually.
  4924.    MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
  4925.    so must be careful about how the stack is used.  */
  4926.  
  4927. static void
  4928. store_one_arg (arg, argblock, may_be_alloca)
  4929.      struct arg_data *arg;
  4930.      rtx argblock;
  4931.      int may_be_alloca;
  4932. {
  4933.   register tree pval = arg->tree_value;
  4934.   int used = 0;
  4935.  
  4936.   if (TREE_CODE (pval) == ERROR_MARK)
  4937.     return;
  4938.  
  4939.   if (arg->reg != 0 && arg->partial == 0)
  4940.     {
  4941.       /* Being passed entirely in a register.  */
  4942.       if (arg->value != 0)
  4943.     {
  4944.       if (GET_MODE (arg->value) == BLKmode)
  4945.         move_block_to_reg (REGNO (arg->reg), arg->value,
  4946.                    ((int_size_in_bytes (TREE_TYPE (pval))
  4947.                  + UNITS_PER_WORD - 1)
  4948.                 / UNITS_PER_WORD));
  4949.       else
  4950.         emit_move_insn (arg->reg, arg->value);
  4951.     }
  4952.       else
  4953.     store_expr (pval, arg->reg, 0);
  4954.  
  4955.       /* Don't allow anything left on stack from computation
  4956.      of argument to alloca.  */
  4957.       if (may_be_alloca)
  4958.     do_pending_stack_adjust ();
  4959.     }
  4960.   else if (TYPE_MODE (TREE_TYPE (pval)) != BLKmode)
  4961.     {
  4962.       register int size;
  4963.       rtx tem;
  4964.  
  4965.       /* Argument is a scalar, not entirely passed in registers.
  4966.      (If part is passed in registers, arg->partial says how much
  4967.      and emit_push_insn will take care of putting it there.)
  4968.      
  4969.      Push it, and if its size is less than the
  4970.      amount of space allocated to it,
  4971.      also bump stack pointer by the additional space.
  4972.      Note that in C the default argument promotions
  4973.      will prevent such mismatches.  */
  4974.  
  4975.       used = size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (pval)));
  4976.       /* Compute how much space the push instruction will push.
  4977.      On many machines, pushing a byte will advance the stack
  4978.      pointer by a halfword.  */
  4979. #ifdef PUSH_ROUNDING
  4980.       size = PUSH_ROUNDING (size);
  4981. #endif
  4982.       /* Compute how much space the argument should get:
  4983.      round up to a multiple of the alignment for arguments.  */
  4984.       if (none != FUNCTION_ARG_PADDING (TYPE_MODE (TREE_TYPE (pval)), const0_rtx))
  4985.     used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
  4986.          / (PARM_BOUNDARY / BITS_PER_UNIT))
  4987.         * (PARM_BOUNDARY / BITS_PER_UNIT));
  4988.  
  4989.       tem = arg->value;
  4990.       if (tem == 0)
  4991.     {
  4992.       tem = expand_expr (pval, 0, VOIDmode, 0);
  4993.       /* ANSI doesn't require a sequence point here,
  4994.          but PCC has one, so this will avoid some problems.  */
  4995.       emit_queue ();
  4996.     }
  4997.  
  4998.       /* Don't allow anything left on stack from computation
  4999.      of argument to alloca.  */
  5000.       if (may_be_alloca)
  5001.     do_pending_stack_adjust ();
  5002.  
  5003.       emit_push_insn (tem, TYPE_MODE (TREE_TYPE (pval)), 0, 0,
  5004.               arg->partial, arg->reg, used - size,
  5005.               argblock, ARGS_SIZE_RTX (arg->offset));
  5006.     }
  5007.   else if (arg->stack != 0)
  5008.     {
  5009.       /* BLKmode parm, not entirely passed in registers,
  5010.      and with space already allocated.  */
  5011.  
  5012.       tree sizetree = size_in_bytes (TREE_TYPE (pval));
  5013.       /* Round the size up to multiple of PARM_BOUNDARY bits.  */
  5014.       tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY);
  5015.       tree s2 = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT);
  5016.  
  5017.       /* Find out if the parm needs padding, and whether above or below.  */
  5018.       enum direction where_pad
  5019.     = FUNCTION_ARG_PADDING (TYPE_MODE (TREE_TYPE (pval)),
  5020.                 expand_expr (sizetree, 0, VOIDmode, 0));
  5021.  
  5022.       /* If it is padded below, adjust the stack address
  5023.      upward over the padding.  */
  5024.  
  5025.       if (where_pad == downward)
  5026.     {
  5027.       rtx offset_rtx;
  5028.       rtx address = XEXP (arg->stack, 0);
  5029.       struct args_size stack_offset;
  5030.  
  5031.       stack_offset.constant = 0;
  5032.       stack_offset.var = 0;
  5033.  
  5034.       /* Compute amount of padding.  */
  5035.       ADD_PARM_SIZE (stack_offset, s2);
  5036.       SUB_PARM_SIZE (stack_offset, sizetree);
  5037.       offset_rtx = ARGS_SIZE_RTX (stack_offset);
  5038.  
  5039.       /* Adjust the address to store at.  */
  5040.       if (GET_CODE (offset_rtx) == CONST_INT)
  5041.         address = plus_constant (address, INTVAL (offset_rtx));
  5042.       else
  5043.         {
  5044.           address = gen_rtx (PLUS, Pmode, address, offset_rtx);
  5045.           address = memory_address (QImode, address);
  5046.         }
  5047.       arg->stack = change_address (arg->stack, VOIDmode, address);
  5048.     }
  5049.  
  5050.       /* ARG->stack probably refers to the stack-pointer.  If so,
  5051.      stabilize it, in case stack-pointer changes during evaluation.  */
  5052.       if (reg_mentioned_p (stack_pointer_rtx, arg->stack))
  5053.     arg->stack = change_address (arg->stack, VOIDmode,
  5054.                      copy_to_reg (XEXP (arg->stack, 0)));
  5055.       /* BLKmode argument that should go in a prespecified stack location.  */
  5056.       if (arg->value == 0)
  5057.     /* Not yet computed => compute it there.  */
  5058.     /* ??? This should be changed to tell expand_expr
  5059.        that it can store directly in the target.  */
  5060.     arg->value = store_expr (arg->tree_value, arg->stack, 0);
  5061.       else if (arg->value != arg->stack)
  5062.     /* It was computed somewhere, but not where we wanted.
  5063.        For example, the value may have come from an official
  5064.        local variable or parameter.  In that case, expand_expr
  5065.        does not fill our suggested target.  */
  5066.     emit_block_move (arg->stack, arg->value, ARGS_SIZE_RTX (arg->size),
  5067.              TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT);
  5068.  
  5069.       /* Now, if this value wanted to be partly in registers,
  5070.      move the value from the stack to the registers
  5071.      that are supposed to hold the values.  */
  5072.       if (arg->partial > 0)
  5073.     move_block_to_reg (REGNO (arg->reg), arg->stack, arg->partial);
  5074.     }
  5075.   else
  5076.     {
  5077.       /* BLKmode, at least partly to be pushed.  */
  5078.  
  5079.       register rtx tem
  5080.     = arg->value ? arg->value : expand_expr (pval, 0, VOIDmode, 0);
  5081.       register int excess;
  5082.       rtx size_rtx;
  5083.  
  5084.       /* Pushing a nonscalar.
  5085.      If part is passed in registers, arg->partial says how much
  5086.      and emit_push_insn will take care of putting it there.  */
  5087.  
  5088.       /* Round its size up to a multiple
  5089.      of the allocation unit for arguments.  */
  5090.  
  5091.       if (arg->size.var != 0)
  5092.     {
  5093.       excess = 0;
  5094.       size_rtx = ARGS_SIZE_RTX (arg->size);
  5095.     }
  5096.       else
  5097.     {
  5098.       register tree size = size_in_bytes (TREE_TYPE (pval));
  5099.       /* PUSH_ROUNDING has no effect on us, because
  5100.          emit_push_insn for BLKmode is careful to avoid it.  */
  5101.       excess = (arg->size.constant - TREE_INT_CST_LOW (size)
  5102.             + arg->partial * UNITS_PER_WORD);
  5103.       size_rtx = expand_expr (size, 0, VOIDmode, 0);
  5104.     }
  5105.  
  5106.       if (arg->stack)
  5107.     abort ();
  5108.  
  5109.       emit_push_insn (tem, TYPE_MODE (TREE_TYPE (pval)), size_rtx,
  5110.               TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT,
  5111.               arg->partial, arg->reg, excess, argblock,
  5112.               ARGS_SIZE_RTX (arg->offset));
  5113.     }
  5114.  
  5115.   /* Once we have pushed something, pops can't safely
  5116.      be deferred during the rest of the arguments.  */
  5117.   NO_DEFER_POP;
  5118. }
  5119.  
  5120. /* Expand conditional expressions.  */
  5121.  
  5122. /* Generate code to evaluate EXP and jump to LABEL if the value is zero.
  5123.    LABEL is an rtx of code CODE_LABEL, in this function and all the
  5124.    functions here.  */
  5125.  
  5126. void
  5127. jumpifnot (exp, label)
  5128.      tree exp;
  5129.      rtx label;
  5130. {
  5131.   do_jump (exp, label, 0);
  5132. }
  5133.  
  5134. /* Generate code to evaluate EXP and jump to LABEL if the value is nonzero.  */
  5135.  
  5136. void
  5137. jumpif (exp, label)
  5138.      tree exp;
  5139.      rtx label;
  5140. {
  5141.   do_jump (exp, 0, label);
  5142. }
  5143.  
  5144. /* Generate code to evaluate EXP and jump to IF_FALSE_LABEL if
  5145.    the result is zero, or IF_TRUE_LABEL if the result is one.
  5146.    Either of IF_FALSE_LABEL and IF_TRUE_LABEL may be zero,
  5147.    meaning fall through in that case.
  5148.  
  5149.    This function is responsible for optimizing cases such as
  5150.    &&, || and comparison operators in EXP.  */
  5151.  
  5152. void
  5153. do_jump (exp, if_false_label, if_true_label)
  5154.      tree exp;
  5155.      rtx if_false_label, if_true_label;
  5156. {
  5157.   register enum tree_code code = TREE_CODE (exp);
  5158.   /* Some cases need to create a label to jump to
  5159.      in order to properly fall through.
  5160.      These cases set DROP_THROUGH_LABEL nonzero.  */
  5161.   rtx drop_through_label = 0;
  5162.   rtx temp;
  5163.   rtx comparison = 0;
  5164.  
  5165.   emit_queue ();
  5166.  
  5167.   switch (code)
  5168.     {
  5169.     case ERROR_MARK:
  5170.       break;
  5171.  
  5172.     case INTEGER_CST:
  5173.       temp = integer_zerop (exp) ? if_false_label : if_true_label;
  5174.       if (temp)
  5175.     emit_jump (temp);
  5176.       break;
  5177.  
  5178.     case ADDR_EXPR:
  5179.       /* The address of something can never be zero.  */
  5180.       if (if_true_label)
  5181.     emit_jump (if_true_label);
  5182.       break;
  5183.  
  5184.     case NOP_EXPR:
  5185.       do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  5186.       break;
  5187.  
  5188.     case TRUTH_NOT_EXPR:
  5189.       do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  5190.       break;
  5191.  
  5192.     case TRUTH_ANDIF_EXPR:
  5193.       if (if_false_label == 0)
  5194.     if_false_label = drop_through_label = gen_label_rtx ();
  5195.       do_jump (TREE_OPERAND (exp, 0), if_false_label, 0);
  5196.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  5197.       break;
  5198.  
  5199.     case TRUTH_ORIF_EXPR:
  5200.       if (if_true_label == 0)
  5201.     if_true_label = drop_through_label = gen_label_rtx ();
  5202.       do_jump (TREE_OPERAND (exp, 0), 0, if_true_label);
  5203.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  5204.       break;
  5205.  
  5206.     case COMPOUND_EXPR:
  5207.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  5208.       emit_queue ();
  5209.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  5210.       break;
  5211.  
  5212.     case COND_EXPR:
  5213.       {
  5214.     register rtx label1 = gen_label_rtx ();
  5215.     drop_through_label = gen_label_rtx ();
  5216.     do_jump (TREE_OPERAND (exp, 0), label1, 0);
  5217.     /* Now the THEN-expression.  */
  5218.     do_jump (TREE_OPERAND (exp, 1),
  5219.          if_false_label ? if_false_label : drop_through_label,
  5220.          if_true_label ? if_true_label : drop_through_label);
  5221.     emit_label (label1);
  5222.     /* Now the ELSE-expression.  */
  5223.     do_jump (TREE_OPERAND (exp, 2),
  5224.          if_false_label ? if_false_label : drop_through_label,
  5225.          if_true_label ? if_true_label : drop_through_label);
  5226.       }
  5227.       break;
  5228.  
  5229.     case EQ_EXPR:
  5230.       comparison = compare (exp, EQ, EQ, EQ, EQ);
  5231.       break;
  5232.  
  5233.     case NE_EXPR:
  5234.       comparison = compare (exp, NE, NE, NE, NE);
  5235.       break;
  5236.  
  5237.     case LT_EXPR:
  5238.       comparison = compare (exp, LT, LTU, GT, GTU);
  5239.       break;
  5240.  
  5241.     case LE_EXPR:
  5242.       comparison = compare (exp, LE, LEU, GE, GEU);
  5243.       break;
  5244.  
  5245.     case GT_EXPR:
  5246.       comparison = compare (exp, GT, GTU, LT, LTU);
  5247.       break;
  5248.  
  5249.     case GE_EXPR:
  5250.       comparison = compare (exp, GE, GEU, LE, LEU);
  5251.       break;
  5252.  
  5253.     default:
  5254.       temp = expand_expr (exp, 0, VOIDmode, 0);
  5255.       /* Copy to register to avoid generating bad insns by cse
  5256.      from (set (mem ...) (arithop))  (set (cc0) (mem ...)).  */
  5257.       if (!cse_not_expected && GET_CODE (temp) == MEM)
  5258.     temp = copy_to_reg (temp);
  5259.       do_pending_stack_adjust ();
  5260.       {
  5261.     rtx zero = CONST0_RTX (GET_MODE (temp));
  5262.  
  5263.     if (GET_CODE (temp) == CONST_INT)
  5264.       comparison = compare_constants (NE, 0,
  5265.                       INTVAL (temp), 0, BITS_PER_WORD);
  5266.     else if (GET_MODE (temp) != VOIDmode)
  5267.       comparison = compare1 (temp, zero, NE, NE, 0, GET_MODE (temp));
  5268.     else
  5269.       abort ();
  5270.       }
  5271.     }
  5272.  
  5273.   /* Do any postincrements in the expression that was tested.  */
  5274.   emit_queue ();
  5275.  
  5276.   /* If COMPARISON is nonzero here, it is an rtx that can be substituted
  5277.      straight into a conditional jump instruction as the jump condition.
  5278.      Otherwise, all the work has been done already.  */
  5279.  
  5280.   if (comparison == const1_rtx)
  5281.     {
  5282.       if (if_true_label)
  5283.     emit_jump (if_true_label);
  5284.     }
  5285.   else if (comparison == const0_rtx)
  5286.     {
  5287.       if (if_false_label)
  5288.     emit_jump (if_false_label);
  5289.     }
  5290.   else if (comparison)
  5291.     {
  5292.       if (if_true_label)
  5293.     {
  5294.       if (bcc_gen_fctn[(int) GET_CODE (comparison)] != 0)
  5295.         emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_true_label));
  5296.       else
  5297.         abort ();
  5298.  
  5299.       if (if_false_label)
  5300.         emit_jump (if_false_label);
  5301.     }
  5302.       else if (if_false_label)
  5303.     {
  5304.       rtx pat;
  5305.  
  5306.       if (bcc_gen_fctn[(int) GET_CODE (comparison)] == 0)
  5307.         abort ();
  5308.  
  5309.       pat = (*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_false_label);
  5310.       /* Now invert the sense of the jump by exchanging the two arms
  5311.          of each IF_THEN_ELSE.  Note that inverting the condition
  5312.          would be incorrect for IEEE floating point with nans!  */
  5313.       if (GET_CODE (pat) == SEQUENCE)
  5314.         {
  5315.           int i;
  5316.           /* We can invert a sequence if the only jump is at the end.  */
  5317.           for (i = 0; i < (int) (XVECLEN (pat, 0) - 1); i++)
  5318.         if (GET_CODE (XVECEXP (pat, 0, i)) == JUMP_INSN)
  5319.           abort ();
  5320.           invert_exp (PATTERN (XVECEXP (pat, 0, XVECLEN (pat, 0) - 1)),
  5321.               0, 0);
  5322.         }
  5323.       else
  5324.         invert_exp (pat, 0, 0);
  5325.  
  5326.       emit_jump_insn (pat);
  5327.     }
  5328.     }
  5329.  
  5330.   if (drop_through_label)
  5331.     emit_label (drop_through_label);
  5332. }
  5333.  
  5334. /* Compare two integer constant rtx's, OP0 and OP1.
  5335.    The comparison operation is OPERATION.
  5336.    Return an rtx representing the value 1 or 0.
  5337.    WIDTH is the width in bits that is significant.  */
  5338.  
  5339. static rtx
  5340. compare_constants (operation, unsignedp, op0, op1, width)
  5341.      enum rtx_code operation;
  5342.      int unsignedp;
  5343.      int op0, op1;
  5344.      int width;
  5345. {
  5346.   int val;
  5347.  
  5348.   /* Sign-extend or zero-extend the operands to a full word
  5349.      from an initial width of WIDTH bits.  */
  5350.   if (width < HOST_BITS_PER_INT)
  5351.     {
  5352.       op0 &= (1 << width) - 1;
  5353.       op1 &= (1 << width) - 1;
  5354.  
  5355.       if (! unsignedp)
  5356.     {
  5357.       if (op0 & (1 << (width - 1)))
  5358.         op0 |= ((-1) << width);
  5359.       if (op1 & (1 << (width - 1)))
  5360.         op1 |= ((-1) << width);
  5361.     }
  5362.     }
  5363.  
  5364.   switch (operation)
  5365.     {
  5366.     case EQ:
  5367.       val = op0 == op1;
  5368.       break;
  5369.  
  5370.     case NE:
  5371.       val = op0 != op1;
  5372.       break;
  5373.  
  5374.     case GT:
  5375.     case GTU:
  5376.       val = op0 > op1;
  5377.       break;
  5378.  
  5379.     case LT:
  5380.     case LTU:
  5381.       val = op0 < op1;
  5382.       break;
  5383.  
  5384.     case GE:
  5385.     case GEU:
  5386.       val = op0 >= op1;
  5387.       break;
  5388.  
  5389.     case LE:
  5390.     case LEU:
  5391.       val = op0 <= op1;
  5392.     }
  5393.  
  5394.   return val ? const1_rtx : const0_rtx;
  5395. }
  5396.  
  5397. /* Generate code for a comparison expression EXP
  5398.    (including code to compute the values to be compared)
  5399.    and set (CC0) according to the result.
  5400.    SIGNED_FORWARD should be the rtx operation for this comparison for
  5401.    signed data; UNSIGNED_FORWARD, likewise for use if data is unsigned.
  5402.    SIGNED_REVERSE and UNSIGNED_REVERSE are used if it is desirable
  5403.    to interchange the operands for the compare instruction.
  5404.  
  5405.    We force a stack adjustment unless there are currently
  5406.    things pushed on the stack that aren't yet used.  */
  5407.  
  5408. static rtx
  5409. compare (exp, signed_forward, unsigned_forward,
  5410.      signed_reverse, unsigned_reverse)
  5411.      register tree exp;
  5412.      enum rtx_code signed_forward, unsigned_forward;
  5413.      enum rtx_code signed_reverse, unsigned_reverse;
  5414. {
  5415.  
  5416.   register rtx op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  5417.   register rtx op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  5418.   register enum machine_mode mode = GET_MODE (op0);
  5419.   int unsignedp;
  5420.  
  5421.   /* If one operand is 0, make it the second one.  */
  5422.  
  5423.   if (op0 == const0_rtx
  5424.       || (GET_MODE_CLASS (mode) == MODE_FLOAT && op0 == CONST0_RTX (mode)))
  5425.     {
  5426.       rtx tem = op0;
  5427.       op0 = op1;
  5428.       op1 = tem;
  5429.       signed_forward = signed_reverse;
  5430.       unsigned_forward = unsigned_reverse;
  5431.     }
  5432.  
  5433.   if (flag_force_mem)
  5434.     {
  5435.       op0 = force_not_mem (op0);
  5436.       op1 = force_not_mem (op1);
  5437.     }
  5438.  
  5439.   do_pending_stack_adjust ();
  5440.  
  5441.   unsignedp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)))
  5442.            || TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1))));
  5443.  
  5444.   if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT)
  5445.     return compare_constants (signed_forward, unsignedp,
  5446.                   INTVAL (op0), INTVAL (op1),
  5447.                   GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))));
  5448.  
  5449.   emit_cmp_insn (op0, op1,
  5450.          (mode == BLKmode) ? expr_size (TREE_OPERAND (exp, 0)) : 0,
  5451.          unsignedp,
  5452.          TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  5453.  
  5454.   return gen_rtx ((unsignedp ? unsigned_forward : signed_forward),
  5455.           VOIDmode, cc0_rtx, const0_rtx);
  5456. }
  5457.  
  5458. /* Like compare but expects the values to compare as two rtx's.
  5459.    The decision as to signed or unsigned comparison must be made by the caller.
  5460.    BLKmode is not allowed.  */
  5461.  
  5462. static rtx
  5463. compare1 (op0, op1, forward_op, reverse_op, unsignedp, mode)
  5464.      register rtx op0, op1;
  5465.      enum rtx_code forward_op, reverse_op;
  5466.      int unsignedp;
  5467.      enum machine_mode mode;
  5468. {
  5469.   /* If one operand is 0, make it the second one.  */
  5470.  
  5471.   if (op0 == const0_rtx
  5472.       || (GET_MODE_CLASS (mode) == MODE_FLOAT && op0 == CONST0_RTX (mode)))
  5473.     {
  5474.       rtx tem = op0;
  5475.       op0 = op1;
  5476.       op1 = tem;
  5477.       forward_op = reverse_op;
  5478.     }
  5479.  
  5480.   if (flag_force_mem)
  5481.     {
  5482.       op0 = force_not_mem (op0);
  5483.       op1 = force_not_mem (op1);
  5484.     }
  5485.  
  5486.   do_pending_stack_adjust ();
  5487.  
  5488.   if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT)
  5489.     return compare_constants (forward_op, unsignedp,
  5490.                   INTVAL (op0), INTVAL (op1),
  5491.                   GET_MODE_BITSIZE (mode));
  5492.  
  5493.   emit_cmp_insn (op0, op1, 0, unsignedp, 0);
  5494.  
  5495.   return gen_rtx (forward_op, VOIDmode, cc0_rtx, const0_rtx);
  5496. }
  5497.  
  5498. /* Generate code to calculate EXP using a store-flag instruction
  5499.    and return an rtx for the result.
  5500.    If TARGET is nonzero, store the result there if convenient.
  5501.  
  5502.    Return zero if there is no suitable set-flag instruction
  5503.    available on this machine.  */
  5504.  
  5505. static rtx
  5506. do_store_flag (exp, target, mode)
  5507.      tree exp;
  5508.      rtx target;
  5509.      enum machine_mode mode;
  5510. {
  5511.   register enum tree_code code = TREE_CODE (exp);
  5512.   register rtx comparison = 0;
  5513.   enum machine_mode compare_mode;
  5514.   rtx prev_insn = get_last_insn ();
  5515.   enum insn_code icode;
  5516.  
  5517.   switch (code)
  5518.     {
  5519. #ifdef HAVE_seq
  5520.     case EQ_EXPR:
  5521.       if (HAVE_seq)
  5522.     {
  5523.       comparison = compare (exp, EQ, EQ, EQ, EQ);
  5524.       icode = CODE_FOR_seq;
  5525.       compare_mode = insn_operand_mode[(int) CODE_FOR_seq][0];
  5526.     }
  5527.       break;
  5528. #endif
  5529.  
  5530. #ifdef HAVE_sne
  5531.     case NE_EXPR:
  5532.       if (HAVE_sne)
  5533.     {
  5534.       comparison = compare (exp, NE, NE, NE, NE);
  5535.       icode = CODE_FOR_sne;
  5536.       compare_mode = insn_operand_mode[(int) CODE_FOR_sne][0];
  5537.     }
  5538.       break;
  5539. #endif
  5540.  
  5541. #if defined (HAVE_slt) && defined (HAVE_sltu) && defined (HAVE_sgt) && defined (HAVE_sgtu)
  5542.     case LT_EXPR:
  5543.       if (HAVE_slt && HAVE_sltu && HAVE_sgt && HAVE_sgtu)
  5544.     {
  5545.       comparison = compare (exp, LT, LTU, GT, GTU);
  5546.       icode = CODE_FOR_slt;
  5547.       compare_mode = insn_operand_mode[(int) CODE_FOR_slt][0];
  5548.     }
  5549.       break;
  5550.  
  5551.     case GT_EXPR:
  5552.       if (HAVE_slt && HAVE_sltu && HAVE_sgt && HAVE_sgtu)
  5553.     {
  5554.       comparison = compare (exp, GT, GTU, LT, LTU);
  5555.       icode = CODE_FOR_slt;
  5556.       compare_mode = insn_operand_mode[(int) CODE_FOR_slt][0];
  5557.     }
  5558.       break;
  5559. #endif
  5560.  
  5561. #if defined (HAVE_sle) && defined (HAVE_sleu) && defined (HAVE_sge) && defined (HAVE_sgeu)
  5562.     case LE_EXPR:
  5563.       if (HAVE_sle && HAVE_sleu && HAVE_sge && HAVE_sgeu)
  5564.     {
  5565.       comparison = compare (exp, LE, LEU, GE, GEU);
  5566.       icode = CODE_FOR_sle;
  5567.       compare_mode = insn_operand_mode[(int) CODE_FOR_sle][0];
  5568.     }
  5569.       break;
  5570.  
  5571.     case GE_EXPR:
  5572.       if (HAVE_sle && HAVE_sleu && HAVE_sge && HAVE_sgeu)
  5573.     {
  5574.       comparison = compare (exp, GE, GEU, LE, LEU);
  5575.       icode = CODE_FOR_sle;
  5576.       compare_mode = insn_operand_mode[(int) CODE_FOR_sle][0];
  5577.     }
  5578.       break;
  5579. #endif
  5580.     }
  5581.   if (comparison == 0)
  5582.     return 0;
  5583.  
  5584.   if (target == 0 || GET_MODE (target) != mode
  5585.       /* Don't use specified target unless the insn can handle it.  */
  5586.       || ! (*insn_operand_predicate[(int) icode][0]) (target, mode)
  5587.       /* When modes don't match, don't use specified target,
  5588.      because it might be the same as an operand,
  5589.      and then the CLOBBER output below would screw up.  */
  5590.       || (mode != compare_mode && GET_CODE (comparison) != CONST_INT))
  5591.     target = gen_reg_rtx (mode);
  5592.  
  5593.   /* Store the comparison in its proper mode.  */
  5594.   if (GET_CODE (comparison) == CONST_INT)
  5595.     emit_move_insn (target, comparison);
  5596.   else if (GET_MODE (target) != compare_mode)
  5597.     {
  5598.       /* We want a different mode: store result in its natural mode.
  5599.      Combine the mode conversion with the truncation we must do anyway.  */
  5600.       /* Put a CLOBBER before the compare, so we don't come between
  5601.      the compare and the insn that uses the result.  */
  5602.       emit_insn_after (gen_rtx (CLOBBER, VOIDmode, target), prev_insn);
  5603.       emit_insn ((*setcc_gen_fctn[(int) GET_CODE (comparison)])
  5604.          (gen_rtx (SUBREG, compare_mode, target, 0)));
  5605.       /* If the desired mode is wider than what we got,
  5606.      use an AND to convert it, but not if we will do one anyway.  */
  5607. #if STORE_FLAG_VALUE == 1
  5608.       if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (compare_mode))
  5609.     expand_bit_and (mode, target, const1_rtx, target);
  5610. #endif
  5611.     }
  5612.   else
  5613.     emit_insn ((*setcc_gen_fctn[(int) GET_CODE (comparison)]) (target));
  5614.  
  5615. #if STORE_FLAG_VALUE != 1
  5616. #if STORE_FLAG_VALUE & 1
  5617.   expand_bit_and (mode, target, const1_rtx, target);
  5618. #else
  5619.   expand_shift (RSHIFT_EXPR, mode, target,
  5620.         build_int_2 (GET_MODE_BITSIZE (mode) - 1, 0),
  5621.         target, TRUE);
  5622. #endif
  5623. #endif
  5624.   return target;
  5625. }
  5626.  
  5627. /* Generate a tablejump instruction (used for switch statements).  */
  5628.  
  5629. #ifdef HAVE_tablejump
  5630.  
  5631. /* INDEX is the value being switched on, with the lowest value
  5632.    in the table already subtracted.
  5633.    RANGE is the length of the jump table.
  5634.    TABLE_LABEL is a CODE_LABEL rtx for the table itself.
  5635.  
  5636.    DEFAULT_LABEL is a CODE_LABEL rtx to jump to if the
  5637.    index value is out of range.  */
  5638.  
  5639. void
  5640. do_tablejump (index, range, table_label, default_label)
  5641.      rtx index, range, table_label, default_label;
  5642. {
  5643.   register rtx temp;
  5644.  
  5645.   emit_cmp_insn (range, index, 0, 0, 0);
  5646.   emit_jump_insn (gen_bltu (default_label));
  5647.   /* If flag_force_addr were to affect this address
  5648.      it could interfere with the tricky assumptions made
  5649.      about addresses that contain label-refs,
  5650.      which may be valid only very near the tablejump itself.  */
  5651.   index = memory_address_noforce
  5652.     (CASE_VECTOR_MODE,
  5653.      gen_rtx (PLUS, Pmode,
  5654.           gen_rtx (MULT, Pmode, index,
  5655.                gen_rtx (CONST_INT, VOIDmode,
  5656.                 GET_MODE_SIZE (CASE_VECTOR_MODE))),
  5657.           gen_rtx (LABEL_REF, VOIDmode, table_label)));
  5658.   temp = gen_reg_rtx (CASE_VECTOR_MODE);
  5659.   convert_move (temp, gen_rtx (MEM, CASE_VECTOR_MODE, index), 0);
  5660.  
  5661.   emit_jump_insn (gen_tablejump (temp, table_label));
  5662. }
  5663.  
  5664. #endif /* HAVE_tablejump */
  5665.